C
cmarsh
I cant figure out why this errors out upon Current.DB.QueryDefs line listed
below. Any help would be appreciated!!
**(This is a form module)
Private Sub Command17_Click()
Dim strSQL As String
If Not Buildsqlstring(strSQL) Then
MsgBox "There was an error!!"
Exit Sub
End If
MsgBox strSQL
CurrentDb.QueryDefs("Reportq").SQL = strSQL
End Sub
Function Buildsqlstring(strSQL As String) As Boolean
Dim strselect As String
Dim strfrom As String
Dim strwhere As String
strselect = "s.* "
strfrom = "[Doc Review T] s "
If chkprogram Then
strwhere = strwhere & " AND s.Program = " & cmbprogram
End If
If chkdocno Then
strwhere = strwhere & " AND s.[Doc No] = " & txtdocno
End If
If chkhwpn Then
strwhere = strwhere & " AND s.[HW PN] = " & txthwpn
End If
If chkqae Then
strwhere = strwhere & " AND s.QAE = " & cmbqae
End If
If chkacc Then
strwhere = strwhere & " AND s.Accepted =" & cmbacc
End If
If chkdate Then
If Not IsNull(txtdatefrom) Then
strwhere = strwhere & " AND s.[Initial Review] >= " & "#"
End If
If Not IsNull(txtdateto) Then
strwhere = strwhere & " AND s.[Initial Review] <= " & "#"
End If
End If
strSQL = "SELECT " & strselect
strSQL = strSQL & "FROM " & strfrom
If strwhere <> "" Then strSQL = strSQL & "WHERE " & Mid$(strwhere, 6)
Buildsqlstring = True
End Function
below. Any help would be appreciated!!
**(This is a form module)
Private Sub Command17_Click()
Dim strSQL As String
If Not Buildsqlstring(strSQL) Then
MsgBox "There was an error!!"
Exit Sub
End If
MsgBox strSQL
CurrentDb.QueryDefs("Reportq").SQL = strSQL
End Sub
Function Buildsqlstring(strSQL As String) As Boolean
Dim strselect As String
Dim strfrom As String
Dim strwhere As String
strselect = "s.* "
strfrom = "[Doc Review T] s "
If chkprogram Then
strwhere = strwhere & " AND s.Program = " & cmbprogram
End If
If chkdocno Then
strwhere = strwhere & " AND s.[Doc No] = " & txtdocno
End If
If chkhwpn Then
strwhere = strwhere & " AND s.[HW PN] = " & txthwpn
End If
If chkqae Then
strwhere = strwhere & " AND s.QAE = " & cmbqae
End If
If chkacc Then
strwhere = strwhere & " AND s.Accepted =" & cmbacc
End If
If chkdate Then
If Not IsNull(txtdatefrom) Then
strwhere = strwhere & " AND s.[Initial Review] >= " & "#"
End If
If Not IsNull(txtdateto) Then
strwhere = strwhere & " AND s.[Initial Review] <= " & "#"
End If
End If
strSQL = "SELECT " & strselect
strSQL = strSQL & "FROM " & strfrom
If strwhere <> "" Then strSQL = strSQL & "WHERE " & Mid$(strwhere, 6)
Buildsqlstring = True
End Function