m7johnson
asked on
stLinkCriteria is not working
Below is my code, when it runs I get a "The Openform action was canceled
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Case Log Add"
stLinkCriteria = "ContactID='" & Me.ContactID & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit
Why is it canceling and not opening the form filtered correctly? I can not figure it out.
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Case Log Add"
stLinkCriteria = "ContactID='" & Me.ContactID & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit
Why is it canceling and not opening the form filtered correctly? I can not figure it out.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, when I change it to
stLinkCriteria = "ContactID=" & Me.ContactID
my form now comes up and it is a blank record and the box containing Contact ID is #Name?
Ideas?
stLinkCriteria = "ContactID=" & Me.ContactID
my form now comes up and it is a blank record and the box containing Contact ID is #Name?
Ideas?
#Name? usually means that something is mis-spelled. Check all of your field and column names.
Also, after your stLinkCriteria line type the below line, run it, and see what it says
msgbox "ContactID is " & Me.ContactID
Also, after your stLinkCriteria line type the below line, run it, and see what it says
msgbox "ContactID is " & Me.ContactID
ASKER
Oh, haha thanks jimhorn.....I had changed the ContactID field on the table from ID to ContactID and forgot to update the form correctly, thanks for pointing it out to me.....
Thanks for the grade. Good luck with your project. -Jim
Is Contact ID a text field (as indicated by your current code)?
If it is a number then you need
stLinkCriteria = "ContactID=" & Me.ContactID
Pete