M
Mark
Hi,
I'm using an unbound form that contains 15 fields from
which the User can enter data to search for records. The
form has fields formatted as text, number, and date/time.
A command button 'On Click' event triggers the query and
returns the records. Usually, a User will not select more
than five fields at the most. My question is; "What is the
proper syntax for when the User does not query on fields
that contain numbers or date/time entries to keep the
query from erroring out?" Often a User will query only on
the END_DATE1 or CONTRACTR1 fields. Alternatively, would
there be another option. A portion of the code is posted
below:
If Not IsNull([Forms]![Form1]![PO_NUMBER]) Then
strWhere = "PO_NUMBER = " & [Forms]![Form1]!
[PO_NUMBER1]
Else
strWhere = "DOLLR_AMT = " & ([Forms]![Form1]!
[DOLLR_AMT1])
strWhere = strWhere & " AND CONTRACTR Like ""*" &
([Forms]![Form1]![CONTRACTR1]) & "*"""
strWhere = strWhere & " AND ORIGINATR Like ""*" &
([Forms]![Form1]![ORIGINATR1]) & "*"""
strWhere = strWhere & " AND STRT_DATE = #" &
([Forms]![Form1]![STRT_DATE1]) & "#"
strWhere = strWhere & " AND END_DATE = #" &
([Forms]![Form1]![END_DATE1]) & "#"
strWhere = strWhere & " AND DESCRIPTN Like ""*" &
([Forms]![Form1]![DESCRIPTN1]) & "*"""
End If
DoCmd.OpenForm "FindContractForm", WhereCondition:=strWhere
Any help would be greatly appreciated. Thanks.
Mark
I'm using an unbound form that contains 15 fields from
which the User can enter data to search for records. The
form has fields formatted as text, number, and date/time.
A command button 'On Click' event triggers the query and
returns the records. Usually, a User will not select more
than five fields at the most. My question is; "What is the
proper syntax for when the User does not query on fields
that contain numbers or date/time entries to keep the
query from erroring out?" Often a User will query only on
the END_DATE1 or CONTRACTR1 fields. Alternatively, would
there be another option. A portion of the code is posted
below:
If Not IsNull([Forms]![Form1]![PO_NUMBER]) Then
strWhere = "PO_NUMBER = " & [Forms]![Form1]!
[PO_NUMBER1]
Else
strWhere = "DOLLR_AMT = " & ([Forms]![Form1]!
[DOLLR_AMT1])
strWhere = strWhere & " AND CONTRACTR Like ""*" &
([Forms]![Form1]![CONTRACTR1]) & "*"""
strWhere = strWhere & " AND ORIGINATR Like ""*" &
([Forms]![Form1]![ORIGINATR1]) & "*"""
strWhere = strWhere & " AND STRT_DATE = #" &
([Forms]![Form1]![STRT_DATE1]) & "#"
strWhere = strWhere & " AND END_DATE = #" &
([Forms]![Form1]![END_DATE1]) & "#"
strWhere = strWhere & " AND DESCRIPTN Like ""*" &
([Forms]![Form1]![DESCRIPTN1]) & "*"""
End If
DoCmd.OpenForm "FindContractForm", WhereCondition:=strWhere
Any help would be greatly appreciated. Thanks.
Mark