cmd button to find record

Steven811

Registered User.
Local time
Today, 13:52
Joined
Apr 18, 2004
Messages
133
Hi

I have a command button on form (A) that I wish to use to open form (B) and display the record that relates to a specific field in form (A). I used the wizard, searched the forums and can't seem to find what I want.

Can anyone suggest the code that I should be using in my on click event?

Thanks in advance

Steven811

PS - Absolute beginner, very simple please.
 
The code behind the button should include a DoCmd.OpenForm. I don't remember the parameters right off the top of my head, but basically, you tell Access to open a form by name, in a particular mode (probably acNormal), and can optionally specify the record criteria used to choose the displayed record. There are a couple of other parameters, but those are the ones you will need. You can look up the Help files to determine how to specify the record on which to open the second form.

Here's a stumbling block: If the selector criterion you supply (as one of the later arguments to the DoCmd.OpenForm) is not unique, you might not get the record you want. Therefore, if you are going to do this, always be sure you have a unique selector criterion available, or that you can live with the alternative.

I'm also making an assumption that you used (or WILL use) the button wizard to build the basic OnClick routine, and that you will go back in to modify it. If that is true, the routine will have its own error handling code already built in, so you can just take advantage of the existing code. Since you say you are new at this, I'll offer the advice that starting with the wizards is never a bad idea even if you have to go back later to customize every single wizarded routine. 'cause at least you know the basic concepts will be right in what the wizard built even if it didn't do 'xactly what you wanted.
 
Thanks

The_Doc_Man said:
The code behind the button should include a DoCmd.OpenForm.


Thanks
 

Users who are viewing this thread

Back
Top Bottom