Go to a specific record (1 Viewer)

FISHiEE

Fish obsessive
Local time
Today, 02:27
Joined
Nov 12, 2004
Messages
86
Hi,

Does anyone know some code that will take me to the record whose field "A" has value "B"?

It sounds very simple but I can't find anything the does it!

Basically I have a table or enquiry records, some of which are related. I just want to be able to click on a button to take the user straight to the related record. The current design does this using a filter but this is pretty rubbish as it meanhs that in order to search on all records I need to select all records again first.
 

RichO

Registered Yoozer
Local time
Yesterday, 20:27
Joined
Jan 14, 2004
Messages
1,036
This is a piece of code from my DB that I use to loop through the recordset to find the desired record and then go to that record:
Code:
    Dim rs As Recordset
    Dim c  As Integer
    Set rs = Me.RecordsetClone
    rs.MoveFirst
    c = 1
    Do While Not rs.EOF
        If InStr(rs!Customer_Name, cboFindCustomer) = 1 Then
            DoCmd.GoToRecord acDataForm, "Customer Maintenance", acGoTo, c
            Exit Do
        End If
        rs.MoveNext
        c = c + 1
    Loop
Perhaps you can adapt this to suit your needs.
 

Users who are viewing this thread

Top Bottom