Load record in form and not data sheet using query

riggsd

Board Regular
Joined
Jan 29, 2003
Messages
143
How do I run a query with a button and get it to load the found record into the form and not bring up a data sheet?

I created the button to run the query and it finds the correct record, but I need it to load the record into my form fields and not in a datasheet.

I'm assuming this would be done using VBA but I don't know how to do that and the information I've found hasn't done what I need to do.

Thanks in advance.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Just have your button open the Form you want, and use your Query as the Data Source of that Form.
 
Upvote 0
Thanks, that worked. I haven't used Access in almost 10 years so have forgotten way too much.
 
Upvote 0
While it works, I can't get it to not open the form if the combo boxes are empty. I've tried adding that to the embedded macro as an if statement, with the open form in the else section but that doesn't seem to be working.
 
Upvote 0
I seldom use embedded macros. Doesn't give you enough control.

You can start out using a macro to get your "basic" functionality. Then I would recommend converting that macro to VBA code by using the "Convert Macros to Visual Basic" functionality. There you can add IF statements and the like to get more control over the process. Then have your Control Button run that VBA code instead of the Macro.
 
Upvote 0
I think that may sometimes depend on whether or not the fields are bound or not.

There is an easy way to find out - try it and see which one works!
That is a lot of what programming is all about, trial and error. So don't be afraid to try it out.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top