Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

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.
0
m7johnson
Asked:
m7johnson
  • 3
  • 2
1 Solution
 
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
 
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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now