runtime error 3141

karl_aks

New member
Local time
Today, 02:47
Joined
May 28, 2019
Messages
1
the Select statement includes a reserved word or an argument name that is misspelled or missing..

basically I want if Ball Grade ,Ball Size & Increment match sch Data table then show partcode

Please help I am a novice at access VBA
Code:
Private Sub textLotSequence2_LostFocus()
' If textLotSequence1 contains 4 valid (non "~") characters then populate label values.
'[Forms]![fSchLabelInput].[comboBallGrade] & " '"
'On Error GoTo textLotSequence2_LostFocus_Error
Dim strSql As String
Dim x As Integer
Dim dbs As Object
Dim rst As DAO.Recordset
Dim recCount As Integer
Dim strTemp As String


strSql = "SELECT [sch Data].[Ball Grade], [sch Data].[Ball Size], "
strSql = strSql & " [sch Data].[Increment], "
strSql = strSql & " [sch Data].[Part Number],"
strSql = strSql & " FROM [sch Data] "

strSql = strSql & " WHERE [Ball Grade] = '" & [Forms]![fschLabelInput].[comboBallGrade] & "'"
strSql = strSql & " AND [Ball Size] = '" & [Forms]![fschLabelInput].[comboBallSize] & "'"
strSql = strSql & " AND [Increment] = '" & [Forms]![fschLabelInput].[comboIncrement] & "'"

Set dbs = Application.CurrentProject
Set rst = dbs.OpenRecordset(strSql, dbOpenDynaset)

[Forms]![fschLabelInput].lblPartNumber.Caption = rst("Part Number")
rst.Close
txtBarcode = Mid(lblBarcode.Caption, 2, 12)




On Error GoTo 0
Exit Sub

textLotSequence2_LostFocus_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure textLotSequence2_LostFocus of Sub Form_fschLabelInput"


End Sub

Thanks in advance
 
Your sql renders to this
Code:
SELECT [sch Data].[Ball Grade]
, [sch Data].[Ball Size]
,  [sch Data].[Increment]
,  [sch Data].[Part Number][SIZE=4][COLOR="Red"][B]
,[/B][/COLOR] [/SIZE]FROM [sch Data]
and the extra comma before FROM is an error.
 
Hi Karl. Welcome to the forum. I agree with jdraw. But if you do a Debug.Print strSql, you can then copy and paste the result in the query designer and you'll be able to see the error better. Cheers!
 

Users who are viewing this thread

Back
Top Bottom