Hi,
First, what is the value stored in strJobIns? If it is from a combo box, make sure it is binding the right column to pass to your form.
Here is what I use to open a form to a record based on a value passed from a combo box:
'==============================================
Dim stDocName As String
Dim stLogin As String
Dim stLinkCriteria As String
stLogin = Me.cboLogin
stLinkCriteria = "[LOGIN_NAME] = " & "'" & stLogin & "'"
stDocName = "frmUserName"
DoCmd.OpenForm stDocName, , , stLinkCriteria
'===============================================
If you start typing "DoCmd.OpenForm ... Then as you add each comma, VBA should show you the information that should come after that comma. The link criteria, or the value to pass, should be right after the third comma after the form name.
In this case, I am passing a login name to a field in my form(underlying table) called "LOGIN_NAME". I had to make sure that the combo box was binding to column 2, since column 1 was the primary key, and column 2 is the actual login name. The login names are unique in my case, but the second column may not be in yours, so you may have to pass to the PK.
Also, VBA tends to respond better if you use variables instead of putting the actual form name in the DoCmd line. In your case...
'=============================
Dim stJobIns
Dim stDocName
Dim stLinkCriteria
stJobIns = "?"
stLinkCriteria = "[RecordKeyField] = "'" & stJobIns & "'"
stDocName = "frmJobDetail"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
'=============================
The DoCmd.Close will close the form that the button was on before the form frmJobDetail opens.
All this code is on the buttons On Click() event.
I hope this helps.
mmcdonal
|