S
stevecrowhurst
Could you guys please cast an eye over my code and give
me a few tips. Thank you for taking the time & trouble to
assist a "newbie"
My problems begin at strFROM could you please help, the
code only produces the following SQL string:
SELECT c.*
FROM tblConsignment AS c;
Some tips and examples of creating would be great, again
thank you all for reading this electronic missive.
Function QBFTest(ByRef strSQL As String) As Boolean
Dim strSELECT As String
Dim strFROM As String
Dim strWHERE As String
strSELECT = "SELECT c.* "
'set an alias "c" for tblConsignment and "h" for HRBaseTbl
strFROM = "FROM tblConsignment AS c "
If chkHRID Then
strFROM = strFROM & " INNER JOIN HRBaseTbl h " & _
"ON c.HRID = h.HRID "
'check for second or more WHERE term
If strWHERE <> """" Then strWHERE = strWHERE & " AND "
strWHERE = h.HRID = " & cboHRID & _"
End If
If ChkCarrier Then
'check for second or more WHERE term
If strWHERE <> " " Then strWHERE = strWHERE & " AND "
strWHERE = strWHERE & "c.ConsignID = " & cboCarrier
End If
strSQL = strSELECT & strFROM
If strWHERE <> "" Then strSQL = strSQL & "WHERE " &
strWHERE
QBFTest = True
End Function
me a few tips. Thank you for taking the time & trouble to
assist a "newbie"
My problems begin at strFROM could you please help, the
code only produces the following SQL string:
SELECT c.*
FROM tblConsignment AS c;
Some tips and examples of creating would be great, again
thank you all for reading this electronic missive.
Function QBFTest(ByRef strSQL As String) As Boolean
Dim strSELECT As String
Dim strFROM As String
Dim strWHERE As String
strSELECT = "SELECT c.* "
'set an alias "c" for tblConsignment and "h" for HRBaseTbl
strFROM = "FROM tblConsignment AS c "
If chkHRID Then
strFROM = strFROM & " INNER JOIN HRBaseTbl h " & _
"ON c.HRID = h.HRID "
'check for second or more WHERE term
If strWHERE <> """" Then strWHERE = strWHERE & " AND "
strWHERE = h.HRID = " & cboHRID & _"
End If
If ChkCarrier Then
'check for second or more WHERE term
If strWHERE <> " " Then strWHERE = strWHERE & " AND "
strWHERE = strWHERE & "c.ConsignID = " & cboCarrier
End If
strSQL = strSELECT & strFROM
If strWHERE <> "" Then strSQL = strSQL & "WHERE " &
strWHERE
QBFTest = True
End Function