Custom find form (1 Viewer)

S

SaraCarbone

Guest
Does anyone have the VBA code for creating a custom find form? I want to create a find form that the user can open and choose a combination of several criteria that will create a filter the user can apply to an inventory form. Like the filters that exist already, but I want to create a nice user interface myself in just one form to apply to a form that lists all the records.
 

Danny Clarke

Registered User.
Local time
Today, 20:40
Joined
Feb 17, 2000
Messages
16
I'm not sure if this is exactly what you're looking for but you could try this:

Private Sub AButtonOnYourForm_Click()

Dim dbs As Database, qdf As QueryDef
Dim val1, val2, val3 As String, strNewTitle As String, StrFilter As String, bo As String

' Return reference to current database.
Set dbs = CurrentDb
' Set search criteria. [Value1] etc. are combo boxes on your find form
StrFilter = "SELECT * FROM YourDb WHERE Field1" & "=" & Forms![Your Form]![Value1] & " AND Field2" & "=" & Forms![Your Form]![Value2] & " AND Field3" & "=" & Forms![Your Form]![Value3]
Set qdf = dbs.CreateQueryDef("YourQuery",StrFilter)

' Apply the filter to your form
DoCmd.ApplyFilter "YourQuery"
End Sub

Hope this is of some use,

Dan
 

Users who are viewing this thread

Top Bottom