One form for multiple queries?

mr_sd

Registered User.
Local time
Today, 09:00
Joined
May 11, 2004
Messages
24
Hi, I was wondering if it's possible to use one form to display the results of different queries.

I have a form to make a booking, an identical form to display booking search results and another identical form to display today's bookings.

When I update the database, I make identical changes to all 3 forms. Is there a way of displaying results in one single form?

Thanks,

Rich.
 
Have you tried using sub forms?
 
You can pass an argument to the form as you open it. The form can use that argument to determine which query to use. As all the queries select the same columns with the same field names, the form will operate correctly.

In the form's Open event:

Code:
Select Case Me.OpenArgs
    Case "A"
        Me.RecordSource = "QueryA"
    Case "B"
        Me.RecordSource = "QueryB"
    Case "C"
        Me.RecordSource = "QueryC"
    Case Else
        MsgBox "No record source specified.  Form will not open", vbOKOnly
        Cancel = True
End Select
 

Users who are viewing this thread

Back
Top Bottom