Query Def

J

jedireg

Vista SP2, Office 2007 Pro SP1

ok here it is.

I have a query ( def below ) which works perfect if I set the sql statement
in the query sql view.

SELECT tblpart_info.rev_date, tblpart_info.usl, tblpart_info.lsl, tblpart_info.max_ra,
tblpart_info_Out_Of_Square, tblpart_info.crown, tblpart_info.comments FROM
tblPart_Info WHERE tblpart_info.part_no="XYZ" AND tblpart_info.operation="ABC"
AND tblpart_info.rev_level="1";

However, when I try to run the following code I get an error message stating:
Run-time Error: '2342' A RunSQL action requires an argument of an SQL statement.

Option Compare Database
Option Explicit

Dim SQLstr As String

Private Sub cmdGetData_Click()

Dim PNum As String
Dim POp As String
Dim PRev As String
cboPartNum.SetFocus
PNum = cboPartNum.Text
cboOperation.SetFocus
POp = cboOperation.Text
cboRev.SetFocus
PRev = cboRev.Text
SQLstr = "SELECT tblpart_info.rev_date, tblpart_info.usl, tblpart_info.lsl,
tblpart_info.max_ra," _
& " tblpart_info_Out_Of_Square, tblpart_info.crown, tblpart_info.comments
FROM tblPart_Info WHERE" _
& " tblpart_info.part_no=" & Chr(34) & PNum & Chr(34) & " AND tblpart_info.operation="
& Chr(34) _
& POp & Chr(34) & " AND tblpart_info.rev_level=" & Chr(34) & PRev & Chr(34)
& ";"
DoCmd.RunSQL SQLstr
End Sub

any thoughts on what I'm doing wrong?
 

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