OK, first, I am no VBA or DBA. I have used DBIII and SBDIV ......some and have used Access for some limited useage, nothing complicated. I am trying to input to a query from a text box. If the input is left blank the the date fields functions as expected and limit the records for the dates between the two parameters. If I input from a drop down box the Crew Leader, a parameter inquiry comes up with the name from the drop down box. If I re-enter the name it works great. If I leave blank .....nothing. So.........I assume that the
stWhere = "[Crew Leader] =" & Me.CmbCl & " And "
blnTrim = True
is mis-typed, wrong syntax, or...................
Entire Sub:
Private Sub CmdGenRepSM_Click()
On Error GoTo Err_CmdGenRepSM_Click
Dim stDocName As String
Dim stWhere As String
Dim stDates As String
Dim blnTrim As Boolean
If Not IsNull(Me.CmbCl) Then
stWhere = "[Crew Leader] =" & Me.CmbCl & " And "
blnTrim = True
End If
If IsNull(Me.txtstartdate) And Me.txtstartdate = "" Then
If Not IsNull(Me.txtenddate) And Me.txtenddate <> "" Then
stWhere = stWhere & "[indate] <=" & Me.txtstartdate & "# and"
blnTrim = True
End If
Else
If IsNull(Me.txtenddate) And Me.txtenddate = "" Then
If Not IsNull(Me.txtstartdate) And Me.txtstartdate <> "" Then
stWhere = stWhere & "[indate]>=" & Me.txtstartdate & "# and "
blnTrim = True
End If
Else
If (Not IsNull(Me.txtstartdate) And Me.txtstartdate <> "") And (Not IsNull(Me.txtenddate) Or Me.txtenddate <> "") Then
stWhere = stWhere & "[indate] Between # " & Me.txtstartdate & "# And #" & Me.txtenddate & " # "
blnTrim = Ytue
End If
End If
End If
If blnTrim Then
stWhere = Left(stWhere, Len(stWhere) - 5)
End If
stDocName = "quesafetymeeting"
DoCmd.OpenReport stDocName, acPreview, , stWhere
Exit_CmdGenRepSM_Click:
Exit Sub
Err_CmdGenRepSM_Click:
MsgBox Err.Description
Resume Exit_CmdGenRepSM_Click
Nav4
stWhere = "[Crew Leader] =" & Me.CmbCl & " And "
blnTrim = True
is mis-typed, wrong syntax, or...................
Entire Sub:
Private Sub CmdGenRepSM_Click()
On Error GoTo Err_CmdGenRepSM_Click
Dim stDocName As String
Dim stWhere As String
Dim stDates As String
Dim blnTrim As Boolean
If Not IsNull(Me.CmbCl) Then
stWhere = "[Crew Leader] =" & Me.CmbCl & " And "
blnTrim = True
End If
If IsNull(Me.txtstartdate) And Me.txtstartdate = "" Then
If Not IsNull(Me.txtenddate) And Me.txtenddate <> "" Then
stWhere = stWhere & "[indate] <=" & Me.txtstartdate & "# and"
blnTrim = True
End If
Else
If IsNull(Me.txtenddate) And Me.txtenddate = "" Then
If Not IsNull(Me.txtstartdate) And Me.txtstartdate <> "" Then
stWhere = stWhere & "[indate]>=" & Me.txtstartdate & "# and "
blnTrim = True
End If
Else
If (Not IsNull(Me.txtstartdate) And Me.txtstartdate <> "") And (Not IsNull(Me.txtenddate) Or Me.txtenddate <> "") Then
stWhere = stWhere & "[indate] Between # " & Me.txtstartdate & "# And #" & Me.txtenddate & " # "
blnTrim = Ytue
End If
End If
End If
If blnTrim Then
stWhere = Left(stWhere, Len(stWhere) - 5)
End If
stDocName = "quesafetymeeting"
DoCmd.OpenReport stDocName, acPreview, , stWhere
Exit_CmdGenRepSM_Click:
Exit Sub
Err_CmdGenRepSM_Click:
MsgBox Err.Description
Resume Exit_CmdGenRepSM_Click
Nav4