Re: Create a multiple parameter search form for a query
- From: "Appelq" <cappelquist@xxxxxxxxx>
- Date: 30 Jun 2006 11:58:38 -0700
On your Prompts form, you should have a [Submit] button that will have
an On-click event to hold some VBA code.
Dim qd As DAO.QueryDef
Dim Whereclause As String
Dim ssql As String
Dim Assignment As Integer
ssql = "SELECT * From table"
IF me!AccountNumber Not NULL Then
Whereclause = " WHERE AccountNumber = " & Me!AccountNumber
End If
IF CustomerAgent Not NULL then
IF Whereclause is NULL Then
whereclause = " WHERE CustomerAgent = " & me!CustomerAgent
Else
Whereclause = " AND CustomerAgent = " & me!CustomerAgent
End IF
END IF
' Make IF statements for each field on the Prompts form.
' At the end you will have a Whereclause that has entries for those
fields that were filled in; or possibly Whereclause will be NULL.
IF Whereclause Not NULL then
ssql = ssql & Whereclause
End IF
'Then execute the ssql or save it as a query and then do whatever other
VBA code you want.
.
- References:
- Prev by Date: Newbie question on formatting a field in table design
- Next by Date: Re: fraction number format?
- Previous by thread: Create a multiple parameter search form for a query
- Next by thread: VB and an Access 2003
- Index(es):