List Box Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I placed the following code behind a list box in my startup switchboard which
opens a specific record in a different form. However, once I'm in the
subsequent form and specified record, I'm not able to access any other
records from within the form. In order for me to use the form properly, I
have to go back out to the switchboard, then use a hyperlink I have set up,
and everything works fine.
Do I need to add something to the code?

Private Sub List42_DblClick(Cancel As Integer)
On Error GoTo Err_List42_DblClick
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmWorkOrder"
stLinkCriteria = "[tblwoWorkOrder#]=" & "'" & Me![List42] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_List42_DblClick:
Exit Sub
Err_List42_DblClick:
MsgBox Err.Description
Resume Exit_List42_DblClick
End Sub

Thanks!
 
In that case don't use the where condition of the open form command line,
instead, pass the value sing the openArgs

DoCmd.OpenForm stDocName, , , , , , Me![List42]

And on the OnLoad event of the frmWorkOrder form, run the code to move to
the desire record

Me.[tblwoWorkOrder#].SetFocus
DoCmd.FindRecord Me.OpenArgs, , True, , True
 
Back
Top