G
Guest
I'm working on a DB in MS 2002. Below is the code. Basically the
Docmd.RunSQL is not working. I can paste the SQL string into a query and it
works just fine. Has anyone had this problem? Please let me know if you see
anything odd. Thanks.
CODE:
Dim strQry As String
Dim strFLT As String
Dim strORD As String
strQry = "SELECT [DNIL_DNIL_MAIN].[CSCI] & [DNIL_DNIL_MAIN].[DNIL_TYPE]
& [DNIL_DNIL_MAIN].[DNIL_NUMBER] AS ID, DNIL_DNIL_MAIN.STATUS,
DNIL_DNIL_MAIN.SUBSYSTEM, DNIL_DNIL_MAIN.PRIORITY,
DNIL_DNIL_MAIN.DESCRIPTION, DNIL_DNIL_OP_IMPACT.OP_IMPACT,
DNIL_DNIL_OP_IMPACT.HOW_TO_TEST, DNIL_DNIL_MAIN.PROGRAM,
DNIL_DNIL_MAIN.PROJECT_NAME FROM DNIL_DNIL_MAIN LEFT JOIN DNIL_DNIL_OP_IMPACT
ON DNIL_DNIL_MAIN.DNIL_NUMBER = DNIL_DNIL_OP_IMPACT.DNIL_NUMBER"
strORD = " ORDER BY [DNIL_DNIL_MAIN].[CSCI] &
[DNIL_DNIL_MAIN].[DNIL_TYPE] & [DNIL_DNIL_MAIN].[DNIL_NUMBER]"
If Me!cboProgram <> "" Then
strFLT = " WHERE [DNIL_DNIL_MAIN].[PROGRAM] = '" & Me!cboProgram &
"' "
ElseIf Me!cboProject <> "" Then
strFLT = " WHERE [DNIL_DNIL_MAIN].[PROJECT_NAME] = '" &
Me!cboProject & "' "
Else
'give them all programs and projects
strFLT = ""
End If
'MsgBox (strFLT)
strQry = strQry & strFLT & strORD & ";"
'MsgBox (strQry)
DoCmd.RunSQL strQry
Docmd.RunSQL is not working. I can paste the SQL string into a query and it
works just fine. Has anyone had this problem? Please let me know if you see
anything odd. Thanks.
CODE:
Dim strQry As String
Dim strFLT As String
Dim strORD As String
strQry = "SELECT [DNIL_DNIL_MAIN].[CSCI] & [DNIL_DNIL_MAIN].[DNIL_TYPE]
& [DNIL_DNIL_MAIN].[DNIL_NUMBER] AS ID, DNIL_DNIL_MAIN.STATUS,
DNIL_DNIL_MAIN.SUBSYSTEM, DNIL_DNIL_MAIN.PRIORITY,
DNIL_DNIL_MAIN.DESCRIPTION, DNIL_DNIL_OP_IMPACT.OP_IMPACT,
DNIL_DNIL_OP_IMPACT.HOW_TO_TEST, DNIL_DNIL_MAIN.PROGRAM,
DNIL_DNIL_MAIN.PROJECT_NAME FROM DNIL_DNIL_MAIN LEFT JOIN DNIL_DNIL_OP_IMPACT
ON DNIL_DNIL_MAIN.DNIL_NUMBER = DNIL_DNIL_OP_IMPACT.DNIL_NUMBER"
strORD = " ORDER BY [DNIL_DNIL_MAIN].[CSCI] &
[DNIL_DNIL_MAIN].[DNIL_TYPE] & [DNIL_DNIL_MAIN].[DNIL_NUMBER]"
If Me!cboProgram <> "" Then
strFLT = " WHERE [DNIL_DNIL_MAIN].[PROGRAM] = '" & Me!cboProgram &
"' "
ElseIf Me!cboProject <> "" Then
strFLT = " WHERE [DNIL_DNIL_MAIN].[PROJECT_NAME] = '" &
Me!cboProject & "' "
Else
'give them all programs and projects
strFLT = ""
End If
'MsgBox (strFLT)
strQry = strQry & strFLT & strORD & ";"
'MsgBox (strQry)
DoCmd.RunSQL strQry