R
rwilliams616
I have a form called QueryForm that allows the user to choose values from 10
combo boxes. I have also included Stephen Lebans' calendar to let the user
filter by dates as well. I get the run-time error 3464 at the DLOOKUP line
near the bottom. All of the combo boxes refer to text data types except for
LogNo, which is a number. I assume the error has something to do with me
needing to place quotation marks somewhere around the text references (such
as Me.cmbPartNo), but whatever I try gives me other errors.
Some other info..."LogNo" is the primary key in the "FRACAS Nov3" table.
"cmdSearch" is the command button that is to be pressed to execute the filter.
Can anyone offer any suggestions? TIA
Private Sub cmdSearch_Click()
Dim varWhere As Variant
varWhere = Null
If Not IsNothing(Me.txtDateFrom) Then
If Not IsDate(Me.txtDateFrom) Then
MsgBox "The value in Date From is not a valid date.",
vbCritical, "Invalid Date"
Exit Sub
End If
If Not IsNothing(Me.txtDateTo) Then
If Not IsDate(Me.txtDateTo) Then
MsgBox "The value in Date To is not a valid date.",
vbCritical, "Invalid Date"
Exit Sub
End If
If Me.txtDateTo < Me.txtDateFrom Then
MsgBox "Date To must be greater than or equal to Date
From.", vbCritical, "Invalid Date"
Exit Sub
End If
Else
If Not IsNothing(Me.txtDateTo) Then
If Not IsDate(Me.txtDateTo) Then
MsgBox "The value in Date To is not a valid date.",
vbCritical, "Invalid Date"
Exit Sub
End If
End If
End If
End If
If Not IsNothing(Me.txtDateFrom) Then
varWhere = (varWhere + " AND ") & "[EventDate] >= #" &
Me.txtDateFrom & "#"
End If
If Not IsNothing(Me.txtDateTo) Then
varWhere = (varWhere + " AND ") & "[EventDate] < #" &
CDate(Me.txtDateTo) + 1 & "#"
End If
If Not IsNothing(Me.cmbPartNo) Then
varWhere = (varWhere + " AND ") & "[PartNo] = " & Me.cmbPartNo
End If
If Not IsNothing(Me.cmbPartNomen) Then
varWhere = (varWhere + " AND ") & "[Nomenclature] = " &
Me.cmbPartNomen
End If
If Not IsNothing(Me.cmbTLPartNo) Then
varWhere = (varWhere + " AND ") & "[NHA_PN] = " & Me.cmbTLPartNo
End If
If Not IsNothing(Me.cmbTLNomen) Then
varWhere = (varWhere + " AND ") & "[NHA_Nomenclature] = " &
Me.cmbTLNomen
End If
If Not IsNothing(Me.cmbLogNo) Then
varWhere = (varWhere + " AND ") & "[LogNo] = " & Me.cmbLogNo
End If
If Not IsNothing(Me.cmbCustomer) Then
varWhere = (varWhere + " AND ") & "[Customer] = " & Me.cmbCustomer
End If
If Not IsNothing(Me.cmbAircraft) Then
varWhere = (varWhere + " AND ") & "[Aircraft] = " & Me.cmbAircraft
End If
If Not IsNothing(Me.cmbWhenOccurred) Then
varWhere = (varWhere + " AND ") & "[WhenOccurred] = " &
Me.cmbWhenOccurred
End If
If Not IsNothing(Me.cmbActionTaken) Then
varWhere = (varWhere + " AND ") & "[ActionTaken] = " &
Me.cmbActionTaken
End If
If Not IsNothing(Me.cmbClosed) Then
varWhere = (varWhere + " AND ") & "[EventClosed] = " & Me.cmbClosed
End If
If IsNothing(varWhere) Then
MsgBox "You must enter at least one search criteria.",
vbInformation, "FRACAS"
Exit Sub
End If
If IsNothing(DLookup("LogNo", "[FRACAS Nov3]", varWhere)) Then
MsgBox "No records meet your criteria.", vbInformation, "No records"
Exit Sub
End If
DoCmd.OpenForm "FRACAS", WhereCondition:=varWhere
DoCmd.Close acForm, Me.name
End Sub
combo boxes. I have also included Stephen Lebans' calendar to let the user
filter by dates as well. I get the run-time error 3464 at the DLOOKUP line
near the bottom. All of the combo boxes refer to text data types except for
LogNo, which is a number. I assume the error has something to do with me
needing to place quotation marks somewhere around the text references (such
as Me.cmbPartNo), but whatever I try gives me other errors.
Some other info..."LogNo" is the primary key in the "FRACAS Nov3" table.
"cmdSearch" is the command button that is to be pressed to execute the filter.
Can anyone offer any suggestions? TIA
Private Sub cmdSearch_Click()
Dim varWhere As Variant
varWhere = Null
If Not IsNothing(Me.txtDateFrom) Then
If Not IsDate(Me.txtDateFrom) Then
MsgBox "The value in Date From is not a valid date.",
vbCritical, "Invalid Date"
Exit Sub
End If
If Not IsNothing(Me.txtDateTo) Then
If Not IsDate(Me.txtDateTo) Then
MsgBox "The value in Date To is not a valid date.",
vbCritical, "Invalid Date"
Exit Sub
End If
If Me.txtDateTo < Me.txtDateFrom Then
MsgBox "Date To must be greater than or equal to Date
From.", vbCritical, "Invalid Date"
Exit Sub
End If
Else
If Not IsNothing(Me.txtDateTo) Then
If Not IsDate(Me.txtDateTo) Then
MsgBox "The value in Date To is not a valid date.",
vbCritical, "Invalid Date"
Exit Sub
End If
End If
End If
End If
If Not IsNothing(Me.txtDateFrom) Then
varWhere = (varWhere + " AND ") & "[EventDate] >= #" &
Me.txtDateFrom & "#"
End If
If Not IsNothing(Me.txtDateTo) Then
varWhere = (varWhere + " AND ") & "[EventDate] < #" &
CDate(Me.txtDateTo) + 1 & "#"
End If
If Not IsNothing(Me.cmbPartNo) Then
varWhere = (varWhere + " AND ") & "[PartNo] = " & Me.cmbPartNo
End If
If Not IsNothing(Me.cmbPartNomen) Then
varWhere = (varWhere + " AND ") & "[Nomenclature] = " &
Me.cmbPartNomen
End If
If Not IsNothing(Me.cmbTLPartNo) Then
varWhere = (varWhere + " AND ") & "[NHA_PN] = " & Me.cmbTLPartNo
End If
If Not IsNothing(Me.cmbTLNomen) Then
varWhere = (varWhere + " AND ") & "[NHA_Nomenclature] = " &
Me.cmbTLNomen
End If
If Not IsNothing(Me.cmbLogNo) Then
varWhere = (varWhere + " AND ") & "[LogNo] = " & Me.cmbLogNo
End If
If Not IsNothing(Me.cmbCustomer) Then
varWhere = (varWhere + " AND ") & "[Customer] = " & Me.cmbCustomer
End If
If Not IsNothing(Me.cmbAircraft) Then
varWhere = (varWhere + " AND ") & "[Aircraft] = " & Me.cmbAircraft
End If
If Not IsNothing(Me.cmbWhenOccurred) Then
varWhere = (varWhere + " AND ") & "[WhenOccurred] = " &
Me.cmbWhenOccurred
End If
If Not IsNothing(Me.cmbActionTaken) Then
varWhere = (varWhere + " AND ") & "[ActionTaken] = " &
Me.cmbActionTaken
End If
If Not IsNothing(Me.cmbClosed) Then
varWhere = (varWhere + " AND ") & "[EventClosed] = " & Me.cmbClosed
End If
If IsNothing(varWhere) Then
MsgBox "You must enter at least one search criteria.",
vbInformation, "FRACAS"
Exit Sub
End If
If IsNothing(DLookup("LogNo", "[FRACAS Nov3]", varWhere)) Then
MsgBox "No records meet your criteria.", vbInformation, "No records"
Exit Sub
End If
DoCmd.OpenForm "FRACAS", WhereCondition:=varWhere
DoCmd.Close acForm, Me.name
End Sub