I have a main form (Cemetery) in this form I have a Map overlayed with a Grid, a ListBox (lstPeople) and a Button (btnEditPeople).
The user can click on a person in the Cemetery form List Box and a Location Box will show where the person is buried.
If the user clicks on the Edit Person button a form will come up showing all the people in the Table (tblPeople). The form shows one person at a time.
I am trying to get the Edit People form to show the person that the user clicked on in the Cemetery form.
I know how to pass the Key Field for the chosen record from the Cemetery form to the Edit People form. That works OK.
The key field in the table tblPeople is (autID). This is set automatically when a person is added to the table.
The first thing I did was to make a holding variable, (numTempID = OpenArgs).
Next I tested the variable (numTempID) to make sure that it is larger than “0”.
Then I tested to see if numTempID is equal to the key field of the current record Me.autID
NOW!! Here is my problem!! How do I “Move” to the “Next” record?
My code:
Code:
Private Sub Form_Load()
Dim numTempID As Integer
Dim txtPersonName As String
If IsNull(OpenArgs) Then 'OpenArgs is the ID number for the record I want, ID is key field.
strOpenArgument = ""
numTempID = 0 'If no OpenArgs then Temp ID is set to 0
Else
numTempID = Val(OpenArgs) 'Temp ID is set to OpenArgs
End If
'Person Name is set to current record to show the table is open (A message box that will be taken out when the code works)
txtPersonName = Me.txtLastName & "," & Me.txtFirstName & " " & Me.txtMiddleName
'MsgBox "Open Arguments = " & Str(numTempID) 'msgbox displays the current records autID - Key Field
If numTempID > 0 Then 'Test to see if Temp ID is larger than "0"
Do While numTempID <> Me.autID 'Test to see if current record is same as search record
-----> 'Move to the next record ‘<----- How do I move to the next record?
MsgBox "Persons ID = " & Str(Me.autID) 'Show the current autID number
Loop 'Loop if Search numTempID is not equal to current record Me.autID
End If