Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2003

    Unanswered: counter problems.....

    I have a counter in my form with the following code

    Function GetID() As Long
    Dim ControlNo As Long
    ControlNo = DLookup("ControlNo", "ControlNo")
    CurrentDb.Execute "update ControlNo set ControlNo=ControlNo+1", dbFailOnError
    GetID = ControlNo
    End Function

    I call this function when I need it in my code...

    WHen I go to place the field on my form of the counter. I have a problem with the mouse scrolling.

    WHat I wanted to do was... change my counter field to unbound.. and then somehow pull the data from the table into my form...

    Also, after the user inputs info into the form.. he/she presses a button to update the record with the correct counter assigned to it...

    then it sound jump to the next number in the counter..

    I'll show you the rest of the code...

    Private Sub Command9_Click()

    Dim RS As Recordset
    Set RS = CurrentDb.OpenRecordset("tblQR", dbOpenTable)
    With RS
    !strProject = strProject.Value
    !strArea = strArea.Value
    !strReference = strReference.Value
    !Site = Site.Value
    '!System = System.Value
    !EPO = EPO.Value
    !ControlNo = ControlNo.Value
    !strDate = strDate.Value

    End With
    MsgBox "Record: " & ControlNo & " has been Added!", vbInformation, "New Project"

    Me.strProject = Null
    Me.strArea = Null
    Me.strReference = Null
    'Me.Site = Null
    'Me.System = Null
    Me.EPO = Null
    Me.strDate = Null

    End If
    End Sub

    thanks for anyhelp

  2. #2
    Join Date
    Feb 2004
    a strange counter function you do have!
    what for are you updating a table, or what object the name "ControlNo" presents?
    MDB, ADP <-> MS SQL + VBA, ADO & RDO, .NET, Oracle, Java/Jsp.

  3. #3
    Join Date
    Jul 2003
    Yes when I click the button on my form.. it adds the record to my table..

    On my form i have a field with my counter on it... ( this is pulled from my table "ControlNo") When the user enters in the record data on the same form and finishes.. he hits a save button which saves the record and saves it under the "controlno" thats in the box on the form..

    but if the user uses the scroll on the mouse it switches to a blank field.. and saves it with no control number to that record...

    So I want to change that field to a unbound field.. that way the wheel on the mouse will not affect the scrolling of the record..

    I'm not at all great with access soo any ideas would be great..


  4. #4
    Join Date
    Feb 2004
    to help I need know your knowledge
    is this you code & are u understend it ?

    CurrentDb.Execute "update ControlNo set ControlNo=ControlNo+1", dbFailOnError
    MDB, ADP <-> MS SQL + VBA, ADO & RDO, .NET, Oracle, Java/Jsp.

  5. #5
    Join Date
    Jul 2003
    I think i got it..

    I changed my allow additions to no.. and the scrolling stop..

    and to answer your question..

    That piece of code was given to me from a friend..


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts