Syntax Error in SQL (1 Viewer)

Minty

AWF VIP
Local time
Today, 03:13
Joined
Jul 26, 2013
Messages
10,366
Debug.print strSQL .

You are missing some spaces between your concatenated SQL String.
 

Zydeceltico

Registered User.
Local time
Yesterday, 22:13
Joined
Dec 5, 2017
Messages
843
Debug.print strSQL .

You are missing some spaces between your concatenated SQL String.

Thanks! Now I am getting "Too few parameters. Expected 1."

with this code:

Code:
Dim QCDB As DAO.Database
Dim rsPart As DAO.Recordset
Dim strSQL As String

Set QCDB = CurrentDb
strSQL = "SELECT Part_ID, PartType, PartDWG " & _
    "FROM tblParts " & _
    "WHERE PartID = " & intPartID

Set rsPart = QCDB.OpenRecordset(strSQL)
        
    Me.txtPartType_FK = rsPart.Fields(0).Value
    Me.txtPartName = rsPart.Fields(1).Value
    Me.txtPartDrawing = rsPart.Fields(2).Value

FWIW - this is the line that is highlighted:
Set rsPart = QCDB.OpenRecordset(strSQL)

Any insight into that error?

Thanks!
 

Minty

AWF VIP
Local time
Today, 03:13
Joined
Jul 26, 2013
Messages
10,366
Debug.print strSQL ?

Please use the above and post up what it says is being passed to your string.
I've been developing on and off for 20 + years and still use it all the time.

I'd place money that your global variable has lost it's value.
 

Zydeceltico

Registered User.
Local time
Yesterday, 22:13
Joined
Dec 5, 2017
Messages
843
Debug.print strSQL ?

Please use the above and post up what it says is being passed to your string.
I've been developing on and off for 20 + years and still use it all the time.

I'd place money that your global variable has lost it's value.

Debug.Print strSQL
SELECT Part_ID, PartType, PartDWG FROM tblParts WHERE tblParts.PartID = 58

It has the correct value.
 

Minty

AWF VIP
Local time
Today, 03:13
Joined
Jul 26, 2013
Messages
10,366
But what it has shown you is that your criteria is using
tblParts.PartID - but your SELECT is using
Part_ID

Spot the _ difference :)
 

Users who are viewing this thread

Top Bottom