Use VBA code to enter parameter criteria

Bob87476

Registered User.
Local time
Today, 04:27
Joined
Oct 4, 2013
Messages
23
I have a query of "Donations" in a sub form and want to use a combo box to specify all donations having a specific date.

is this a job for VBA code? or is there some other way.


I have uploaded the file.
just open frmQryDonationsByBatchDate and hopefully it will make sense.
 

Attachments

Basically I have made some changes to the controls on your form. I replaced your embedded query with a list box named "lstDonations" and then used your query as the record source for this new list box. I renamed your combo to "cboBatchDate" and made it to only have one column (the batch date field). In this case you need to have the date to be bound to the combo box control so you can have that value to be the criteria for your query. I then added a reference to the criteria for the BatchDate field in the query.

I have also added only one line of VBA code to the AfterUpdate event of the combo box. Take at look at that line of code.

Open your form and select a Batch Date. If there are records where the batch date is equal to the Batch Date you select, they will be displayed in the combo box.

Hope this helps.
 

Attachments

Basically I have made some changes to the controls on your form. I replaced your embedded query with a list box named "lstDonations" and then used your query as the record source for this new list box. I renamed your combo to "cboBatchDate" and made it to only have one column (the batch date field). In this case you need to have the date to be bound to the combo box control so you can have that value to be the criteria for your query. I then added a reference to the criteria for the BatchDate field in the query.

I have also added only one line of VBA code to the AfterUpdate event of the combo box. Take at look at that line of code.

Open your form and select a Batch Date. If there are records where the batch date is equal to the Batch Date you select, they will be displayed in the combo box.

Hope this helps.

Sounds great but please check the file you uploaded because it doesn't have any of the elements that you spoke of in your text.
 
Well, I do not know what happened but here is the file that does have the changes.
 

Attachments

Users who are viewing this thread

Back
Top Bottom