D
Dan
I have developed the following code from a query that I have confirmed
works. I want to now get it to run using VBA. The problem is that my AND
lines do not work. The OR lines are working though. Any help would be
appreciated:
Private Sub cboCompany_AfterUpdate()
cboCompany.Requery
cboWpnTypeEdit1 = Null
Dim strRType As String
Dim strCo As String
strCo = "SELECT DISTINCT TAMCN.[NOMEN], TAMCN.[ID], Serials.[Bn],
Serials.[Co] " & _
"FROM TAMCN " & _
"INNER JOIN Serials ON TAMCN.[ID] = Serials.[ID]" & _
"WHERE Serials.Bn ='" & Me.cboBn.Value & "' " & _
"AND Serials.Bn ='" & Me.cboCompany.Value & "' " & _
"AND TAMCN.[ID] = '05538C'" & _
"OR TAMCN.[ID] = '05538D'" & _
"OR TAMCN.[ID] = '05538B'" & _
"OR TAMCN.[ID] = '02648A'" & _
"OR TAMCN.[ID] = '02468B'" & _
"OR TAMCN.[ID] = '05539B'" & _
"OR TAMCN.[ID] = '05539D'" & _
"OR TAMCN.[ID] = '09592A'" & _
"OR TAMCN.[ID] = '09629B'" & _
"OR TAMCN.[ID] = '10012B'" & _
"OR TAMCN.[ID] = '10012A'" & _
"OR TAMCN.[ID] = '02648C';"
cboWpnTypeEdit1.RowSource = strCo
strRType = "SELECT * FROM TAMCN "
strRType = strRType & " WHERE TAMCN.RowField = '" & cboCo & "'"
Me.RecordSource = strRType
cboWpnTypeEdit1.Requery
End Sub
works. I want to now get it to run using VBA. The problem is that my AND
lines do not work. The OR lines are working though. Any help would be
appreciated:
Private Sub cboCompany_AfterUpdate()
cboCompany.Requery
cboWpnTypeEdit1 = Null
Dim strRType As String
Dim strCo As String
strCo = "SELECT DISTINCT TAMCN.[NOMEN], TAMCN.[ID], Serials.[Bn],
Serials.[Co] " & _
"FROM TAMCN " & _
"INNER JOIN Serials ON TAMCN.[ID] = Serials.[ID]" & _
"WHERE Serials.Bn ='" & Me.cboBn.Value & "' " & _
"AND Serials.Bn ='" & Me.cboCompany.Value & "' " & _
"AND TAMCN.[ID] = '05538C'" & _
"OR TAMCN.[ID] = '05538D'" & _
"OR TAMCN.[ID] = '05538B'" & _
"OR TAMCN.[ID] = '02648A'" & _
"OR TAMCN.[ID] = '02468B'" & _
"OR TAMCN.[ID] = '05539B'" & _
"OR TAMCN.[ID] = '05539D'" & _
"OR TAMCN.[ID] = '09592A'" & _
"OR TAMCN.[ID] = '09629B'" & _
"OR TAMCN.[ID] = '10012B'" & _
"OR TAMCN.[ID] = '10012A'" & _
"OR TAMCN.[ID] = '02648C';"
cboWpnTypeEdit1.RowSource = strCo
strRType = "SELECT * FROM TAMCN "
strRType = strRType & " WHERE TAMCN.RowField = '" & cboCo & "'"
Me.RecordSource = strRType
cboWpnTypeEdit1.Requery
End Sub