VBA to Open Form With Custom Query

G

ghadley_00

Hi,

I have an MS access database form that during creation of a new entry
checks to see if that entry already exists in a table (using code
triggered as part of the afterupdate event).

At present a message box is triggered, however, I would like to have a
second form open with it's data source being a query for all the
records that have the matching field (e.g. Name).

Is there a way to open an existing form and define its data source via
VBA?

Thanks,

George Hadley
(e-mail address removed)
 
R

Rick Brandt

Hi,

I have an MS access database form that during creation of a new entry
checks to see if that entry already exists in a table (using code
triggered as part of the afterupdate event).

At present a message box is triggered, however, I would like to have a
second form open with it's data source being a query for all the
records that have the matching field (e.g. Name).

Is there a way to open an existing form and define its data source via
VBA?

Sounds like all you need to do is open the form with an appropriate WHERE
clause. That ability is built right into the OpenForm method and there is even
a wizard that will write the code for you.
 

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