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.
m7johnsonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>stLinkCriteria = "ContactID='" & Me.ContactID & "'"
If ContactId is numeric and not text, then lose the single quote marks, like this...

stLinkCriteria = "ContactID=" & Me.ContactID
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
peter57rCommented:
Hi m7johnson,
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
0
m7johnsonAuthor Commented:
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?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
#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
0
m7johnsonAuthor Commented:
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.....
0
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Thanks for the grade.  Good luck with your project.  -Jim
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.