Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Error 4

Status
Not open for further replies.

jdwm2310

Technical User
Jul 26, 2001
396
0
0
US
hi,

i inserted a code under the dbl click of a listbox.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "SERP Employees"
stLinkCriteria "[EmployeeName]='" & "'" & Me![List10]& "'"
DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria

but I am getting syntax errors.


I want to dblclick on a person's name listed in the listbox. When I dblclick I will be transported to that person's record in the SERP Employees Form. Any suggestions.
 
Hi,

I think it should read
stLinkCriteria = "[EmployeeName]='" & "'" & Me![List10]& "'"

Nick
 
Maybe try:

stLinkCriteria = "[EmployeeName]='" & Me![List10]& "'"

Nick
 
I usually set up an invisible text box on the form, assign the column that you want, and use that text box as the criteria to open the form:
Code:
Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "SERP Employees"

    TxtYourTextBox = Me![List10].Column(0)  
    stLinkCriteria "[EmployeeName] = TxtYourTextBox"
    DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria
 
i think the right syntax is:

stLinkCriteria = "[EmployeeName]='" & Me![List10]& "'"

hope it works!
Skep :)
 
HI CosmoKramer,

I inserted this code and now I get compile error.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "SERP Employees"
Text16 = Me![List10].Column(0)
stLinkCriteria "[EmployeeName]=Text16"

DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria
 
Hi Nickjar2 & Skeptik,

I inserted the coding you guys mentioned but when I dble click I am taken to the form but it's blank. Any suggestions.
 
Hi!

Try this:

stLinkCriteria = "[EmployeeName]='" & Me![List10] & "'"

or

Text16 = Me![List10].Column(0)
stLinkCriteria "[EmployeeName] = '" & Text16 & "'"

One of those should handle it. Please note the spacing around the ampersands.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Sorry, I forgot an equal sign...Should be:

stLinkCriteria = "[EmployeeName]=Text16"

 
Hi! i'm not sure about this, but try this:

stLinkCriteria = ("[EmployeeName]='" & Me![List10]& "'")

i think he's getting confused due to the 2 equal signs!
instead of using the stlinkcriteria why don't you try to just insert the code in the expression, like this:

DoCmd.OpenForm stDocName, acNormal, , "[EmployeeName]='" & Me![List10]& "'"

 
Thanks everyone, Jerby I entered your code and it worked!!!!! The problem was that my field name did not match the field name in the form. (Duh, silly me)
Thanks you guys for everything, you were all really helpful!!B-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top