Parameter value being asked for

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am defining the recordsource in the open event of a new form as follows:

Me.RecordSource = "Select [tbl_History].* From [tbl_History] " & _
"Where [HistAccountNo] = 1 And [HistLastname] = Smith"

When I open this form I get an "Enter Parameter Value" box looking for a
value for "Smith". Why is this happening?

ctdak
 
Presumably HistLastname is a Text type field, so you need quotes around the
literal value:

Me.RecordSource = "Select [tbl_History].* From [tbl_History] " & _
"Where ([HistAccountNo] = 1) And ([HistLastname] = ""Smith"");"

If those quotes don't make sense, see:
Quotation marks within quotes
at:
http://allenbrowne.com/casu-17.html
 
Thanks again. I knew I had run into this before but couldn't remember when
or what the solution was.
ctdak


Allen Browne said:
Presumably HistLastname is a Text type field, so you need quotes around the
literal value:

Me.RecordSource = "Select [tbl_History].* From [tbl_History] " & _
"Where ([HistAccountNo] = 1) And ([HistLastname] = ""Smith"");"

If those quotes don't make sense, see:
Quotation marks within quotes
at:
http://allenbrowne.com/casu-17.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

ctdak said:
I am defining the recordsource in the open event of a new form as follows:

Me.RecordSource = "Select [tbl_History].* From [tbl_History] " & _
"Where [HistAccountNo] = 1 And [HistLastname] = Smith"

When I open this form I get an "Enter Parameter Value" box looking for a
value for "Smith". Why is this happening?
 

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

Back
Top