Hi there Ive created some SQL code in the Click event of a submit button. I had it working at the start but when i made a few modifications it keep telling me that and end of statement is required . The strings are retrieved from combo box values and then stored in string variables that are assigned to the SQL string.
Can anyone please point me in the right direction
Regards Panteraboy
Code:
Private Sub CmdSubmit_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Dim operatingsystem As String
Dim make As String
Dim computertype As String
Set db = CurrentDb
Set qdf = db.QueryDefs("Admin_query")
If (Me.CboOS.Value = "All") Then
operatingsystem = " Like '*' "
Else
operatingsystem = "='" & Me.CboOS.Value & "' "
End If
If (Me.CboMake.Value = "All") Then
make = " Like '*' "
Else
make = "='" & Me.CboMake.Value = "='" & "' "
End If
'below is only two of the many SQL variations ive tried
' strSQL = "SELECT laptops.* " & _
' "FROM laptops " & _
' "WHERE laptops.operating_sysytem" & operatingsystem & _
'"AND laptops.manufacturer" & make ;"
' strSQL = "SELECT laptops.* " & _
' "FROM laptops " & _
' "WHERE laptops.[operating_sysytem] = '" & operatingsystem & "' "& _
' "AND laptops.[manufacturer]= '" & make & "' " ;"
qdf.SQL = strSQL
DoCmd.OpenQuery "Admin_query"
DoCmd.Close acForm, Me.Name
' MsgBox strSQL
Set qdf = Nothing
Set db = Nothing
DoCmd.OpenForm "laptop_specs", , "Admin_query
End Sub
Regards Panteraboy
Comment