Query in VBA code

utzja1

Registered User.
Local time
Today, 17:25
Joined
Oct 18, 2012
Messages
97
I have a form with a macro button on it; the form is bound to a query. The intent is that the User supplies a piece of data in the field next to the macro button, and then when the User clicks the button, a macro launches that validates the data. If the value is valid, then the macro is supposed to run a query so that all records with this value are returned. The User can then use the record-selector arrows at the bottom of the form to move through the data set.

When running a query from VBA, what is the proper protocol for running a query that serves as a record source for a form? I want to run the query but not show it explicitly. Do I need to create a record set to do this, or will DoCmd.OpenQuery do what I want in the background?

Thanks for the time and consideration.
 
Thanks, that was actually my first strategy, but I'm pulling data from multiple tables and that was proving to be more trouble than it was worth. I have also had exchanges with Super Moderators on this form that said a filter was inefficient with large data sets, since the entire data set had to be loaded before it could be filtered.

I'll keep working on this and post back if I have success.
 
Problem solved; when the macro button is clicked, it launches a macro with an If-Then-Else construct. The If-Then portion verifies that it's a valid search value, if so, then the Else portion re-queries the form.
 

Users who are viewing this thread

Back
Top Bottom