Filter / Query From Unbound Form to Bound Form?

G

Guest

Hello Sirs

I currently have a form with numerous fields:

CboName, CboRegion, CboCategory, TxtIns

All of these fields i've placed bound on a form (linked to the main table).

I designed an additional interface (form) for all of the drop-down boxes, that should somehow allow the user to search/filter by the different criteria in the drop-downs and texts field to help search the table and appear filtered/search on the bound form

Basically I don't know the code to search whatever fields are contained in the unbound search form and to filter the bound form based on the criteria in that unbound form.

I tried doing some outlandish code enclosed below
__________________beginning of my code_____
Private Sub CmdOK_Click(
On Error GoTo Err_CmdOK_Clic
Dim strSQL As Strin
strSQL = "
If Len(Me.CmbFilter & vbNullString) = 0 The
MsgBox "Please select one of the options.", vbInformation, "Selection Required
ElseIf Me.CmbFilter = "See All" The
DoCmd.OpenForm "Web Status Clients Form Test New Filter
DoCmd.Close acForm, "Web Status Clients Search Form w Filters
ElseIf Me.CmbFilter = "Filter By.." The
If IsNull(Me!CmbRegions) = False The
If Len(strSQL) = 0 The
strSQL = strSQL & "Region = '" & Me.CmbRegions & "'
Els
strSQL = strSQL & " AND Region = '" & Me.CmbRegions & "'
End I
End I
DoCmd.OpenForm "Web Status Clients Form Test New Filter", acNormal, strSQ
DoCmd.Close acForm, "Web Status Clients Search Form w Filters
End I
Exit_CmdOK_Click
Exit Su
Err_CmdOK_Click
MsgBox Err.Descriptio
Resume Exit_CmdOK_Clic
End Su
______

But this does not filter the form for me at all. Any help
Hope this makes it easier to understand what I am trying to accomplish

With respect
Sñr. Alfonzo Edgard

PS Get Dirk on the job...he's Primo
 
R

Rod Scoullar

Alfonzo,

You are close, try

Private Sub CmdOK_Click()
Dim strLink as String
Dim strSQL as String

If Not IsNull(cboName) then
strSQL = strSQL & strLink & "Name=""" & cboName & """" (assumes a
string not an number)
strLink = " And "
End If
If Not IsNull(cboRegion) then
strSQL = strSQL & strLink & "Region=""" & cboName & """"
strLink = " And "
End If

and so on until each combo or text box has been tested.

DoCmd.OpenForm "Web Status Clients Form Test New Filter", acNormal,
strSQL

rest of your code.

Rod Scoullar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top