Problems with data collection

J

John

I'm hoping someone can help with this.

I have a form I've created for user input that will storer
the data to one or many tables and pull up relevant forms
with the given information in place.

Everything seems to be working out, but the query that the
form generates is not reading the WHERE statement of my
SQL. When I check the query in design mode, all the data
is there, but it won't run the querey until I manually
place quotes around the data passed through the WHERE
statement.

Here's my code:

Dim sSELECT As String
Dim sFROM As String
Dim sWHERE As String
Dim sSQL As String

sSELECT = "w.chrPDR, w.dtmID, w.chrStyle, w.chrDesc, " & _
"w.chrIdentCode "
sFROM = "tblWorkOrders AS w "
sWHERE = "chrPDR = " & txtPDR
sSQL = "SELECT " & sSELECT
sSQL = sSQL & "FROM " & sFROM
sSQL = sSQL & "WHERE " & sWHERE

Thank you
 
M

Marshall Barton

John said:
I'm hoping someone can help with this.

I have a form I've created for user input that will storer
the data to one or many tables and pull up relevant forms
with the given information in place.

Everything seems to be working out, but the query that the
form generates is not reading the WHERE statement of my
SQL. When I check the query in design mode, all the data
is there, but it won't run the querey until I manually
place quotes around the data passed through the WHERE
statement.

Here's my code:

Dim sSELECT As String
Dim sFROM As String
Dim sWHERE As String
Dim sSQL As String

sSELECT = "w.chrPDR, w.dtmID, w.chrStyle, w.chrDesc, " & _
"w.chrIdentCode "
sFROM = "tblWorkOrders AS w "
sWHERE = "chrPDR = " & txtPDR
sSQL = "SELECT " & sSELECT
sSQL = sSQL & "FROM " & sFROM
sSQL = sSQL & "WHERE " & sWHERE


Is chrPDR a Text field? If so, you need to put quotes
around the value:

sWHERE = "chrPDR = """ & txtPDR & """"
 

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

Similar Threads


Top