Help with Where Condition in OpenForm Expression

G

Guest

I have a form (frmLogin) with a combo box where users select their User Name
(Authors). I have an OpenForm expression to limit the results of the 2nd form
to a name that matches the name listed in the combo box of the first form. I
tried the follwoing with no luck.

The "Authors" combo box lists user names in "Last, First" name format. I get
an error: "Syntax Error (comma) in query expression 'Lead= last, first'.

"last, first" being the name found in the combo box.

What am I doing wrong here?

Dim stDocName As String
Dim stAuthors As String

stDocName = "Tracking"
stAuthors = Forms![frmLogin]![Authors]

DoCmd.OpenForm stDocName, acNormal, , "Lead =" & stAuthors, acFormEdit
 
F

fredg

I have a form (frmLogin) with a combo box where users select their User Name
(Authors). I have an OpenForm expression to limit the results of the 2nd form
to a name that matches the name listed in the combo box of the first form. I
tried the follwoing with no luck.

The "Authors" combo box lists user names in "Last, First" name format. I get
an error: "Syntax Error (comma) in query expression 'Lead= last, first'.

"last, first" being the name found in the combo box.

What am I doing wrong here?

Dim stDocName As String
Dim stAuthors As String

stDocName = "Tracking"
stAuthors = Forms![frmLogin]![Authors]

DoCmd.OpenForm stDocName, acNormal, , "Lead =" & stAuthors, acFormEdit

It appears the bound column of [Authors] is a text datatype. It's
value must be within quotes.

All you need is just this one line.

DoCmd.OpenForm "Tracking", , , "[Lead] = """ & Me![Authors] & """"

acNorma; and acFormEdit are both default properties and need not be
explicitly written.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top