S
stevecrowhurst
I have redone the code and the function is now written
like this:
Function QBFTest1(ByRef strSQL As String) As Boolean
Dim strSELECT As String
Dim strFROM As String
Dim strWHERE As String
strSELECT = "SELECT tblConsignment.ConsignID,
tblConsignment.Carrier, HRBaseTbl.FirstName,
HRBaseTbl.Surname "
strFROM = "FROM HRBaseTbl INNER JOIN tblConsignment ON
HRBaseTbl.HRID = tblConsignment.HRID "
If strWHERE <> "" Then strWHERE = strWHERE & " AND "
strWHERE = strWHERE & "tblConsignment.HRID = " &
cboHRID
If ChkCarrier = True Then
'check for second or more WHERE term
If strWHERE <> " " Then strWHERE = strWHERE & " AND "
strWHERE = strWHERE & "tblConsignment.ConsignID = " &
cboCarrier
End If
strSQL = strSELECT & strFROM
If strWHERE <> "" Then strSQL = strSQL & "WHERE " &
strWHERE
QBFTest1 = True
End Function
If I debug this function I get:
SELECT tblConsignment.ConsignID, tblConsignment.Carrier,
HRBaseTbl.FirstName, HRBaseTbl.Surname FROM HRBaseTbl
INNER JOIN tblConsignment ON HRBaseTbl.HRID =
tblConsignment.HRID WHERE tblConsignment.HRID =
Running the function produces runtime error 3075
Again thank you for your time and trouble.
like this:
Function QBFTest1(ByRef strSQL As String) As Boolean
Dim strSELECT As String
Dim strFROM As String
Dim strWHERE As String
strSELECT = "SELECT tblConsignment.ConsignID,
tblConsignment.Carrier, HRBaseTbl.FirstName,
HRBaseTbl.Surname "
strFROM = "FROM HRBaseTbl INNER JOIN tblConsignment ON
HRBaseTbl.HRID = tblConsignment.HRID "
If strWHERE <> "" Then strWHERE = strWHERE & " AND "
strWHERE = strWHERE & "tblConsignment.HRID = " &
cboHRID
If ChkCarrier = True Then
'check for second or more WHERE term
If strWHERE <> " " Then strWHERE = strWHERE & " AND "
strWHERE = strWHERE & "tblConsignment.ConsignID = " &
cboCarrier
End If
strSQL = strSELECT & strFROM
If strWHERE <> "" Then strSQL = strSQL & "WHERE " &
strWHERE
QBFTest1 = True
End Function
If I debug this function I get:
SELECT tblConsignment.ConsignID, tblConsignment.Carrier,
HRBaseTbl.FirstName, HRBaseTbl.Surname FROM HRBaseTbl
INNER JOIN tblConsignment ON HRBaseTbl.HRID =
tblConsignment.HRID WHERE tblConsignment.HRID =
Running the function produces runtime error 3075
Again thank you for your time and trouble.