Results 1 to 8 of 8
  1. #1
    Lounger
    Join Date
    Jan 2005
    Location
    Jacksonville, North Carolina, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    GoTo question(s) (2000 sp3)

    I'd like to create my own "Navigation Buttons" in my form. I've made the command buttons, but the field where you can type the record number is getting the better of me. Also ... I don't have my record numbers starting at one, so ... is there any way that I can create a Navigation field that will search through my table's primary key (which is an autonumber)?

    Thanks in advance,

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: GoTo question(s) (2000 sp3)

    You can use a text box with Control Source =[CurrentRecord] to display the record number.

    Would you like the "Navigation field" to search as the user types (e.g. the user types 6, the form jumps to the record with key = 6, the user types 1, the form jumps to the record with key = 61, the user types 3, the form jumps to the record with key = 613 etc.), or would you prefer a "Search" button next to the text box?

  3. #3
    Lounger
    Join Date
    Jan 2005
    Location
    Jacksonville, North Carolina, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: GoTo question(s) (2000 sp3)

    Sorry for taking so long to respond.

    Your first suggestion sounds like it'll work great. I was just looking for a field where they type a number and the form goes to that record ... it doesn't have to be as the user types it in, so I guess which ever is easier.

    V/R

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: GoTo question(s) (2000 sp3)

    Just to make sure: if the user types, say, 37, do you want to go to the 37th record in the form, or to the record for which the AutoNumber field has value 37?

  5. #5
    Lounger
    Join Date
    Jan 2005
    Location
    Jacksonville, North Carolina, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: GoTo question(s) (2000 sp3)

    the record for which the AutoNumber field has value 37.

    Thank you,

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: GoTo question(s) (2000 sp3)

    Make sure that you have a reference to the Microsoft DAO 3.6 Object Library in Tools | References... in the Visual Basic Editor.

    Let's say that the text box is named txtSearch, and that the AutoNumber field is named ID. Set the Format property of the text box to General Number. Here is code to use for moving to a record as the user types:

    Private Sub txtSearch_Change()
    Dim rst As DAO.Recordset
    Dim strSearch As String

    On Error GoTo ErrHandler

    If IsNull(Me.txtSearch) Then Exit Sub

    Set rst = Me.RecordsetClone
    strZoek = "[ID] = " & Me.txtSearch.Text
    rst.FindFirst strZoek
    If rst.NoMatch Then
    Beep
    Else
    If Me.Dirty Then RunCommand acCmdSaveRecord
    Me.Bookmark = rst.Bookmark

    ExitHandler:
    Me.txtSearch.SelStart = Len(Me.txtSearch.Text)
    Exit Sub

    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Sub

  7. #7
    Lounger
    Join Date
    Jan 2005
    Location
    Jacksonville, North Carolina, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: GoTo question(s) (2000 sp3)

    Hans ... I have to say ... you're a genius. I did change one thing though. I had to put it in After_Update due to the fact that I don't have any forms between 1 and 9 ... so it beeps a couple of times before getting to the right record. No matter ... It's perfect now. Thank you again!!

    V/R

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: GoTo question(s) (2000 sp3)

    If you use the After Update event, you can use txtSearch instead of txtSearch.Text. Otherwise, the code can be used without modification.

Posting Permissions

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