Problems with data collection

  • Thread starter Thread starter John
  • Start date Start date
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
 
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 & """"
 
Back
Top