Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking to forms via command buttons

Status
Not open for further replies.

42keys

Programmer
Apr 11, 2001
6
US
I'm making a database to track my customers, I have a main customer form with some basic info. I have a command button that opens another more detailed form that would pertain to the customer I'm viewing at the time.

My dilemma: When I bring up the second form, I need the customer's name to automatically show on the form. (Within a combobox or textbox.)

I would appreciate any help on this matter.
 
Hi!

You don't show how you are opening the form, but I will assume that the form's record sourse is limited by the customer chosen in the first form. The easiest way to do what you want is to build the second form on a query and include the customer's name in the query and you can then add a textbox with the customer's name as its control source.

If that isn't satisfactory, then you can pass the customer's name to the new for via the OpenArgs property, assuming you are using VBA to open the form:

DoCmd.OpenForm FormName, , , WhereCondition, , , CustomerName

Then add an unbound text box to the second form and put the following code in the Form_Load event procedure:

If IsNull(Me.OpenArgs) = False Then
textbox = Me.OpenArgs
End If

hth
Jeff Bridgham

 
Thanks for the help, Jeff!

I hope this will work. In the VBA code you have "wherestatement", What should I put here?

Thanks Again,
42keys
 
Hi!

It might help if you show me how you are opening the form, but, if you used the command button wizard to open the form to the appropriate record, then look for the DoCmd.OpenForm line and add enough commas to total six and then put the name of the textbox where the customer name is.

If that doesn't help then I will need more information to give you a complete answer.

hth
Jeff Bridgham
 
Hey Jeff! Your advice is really helping me out!

Now when I open the form the correct Customer is displayed :)... but the other data on the second form doesn't change when I goto a new customer!?!

I look at the second form's table and it only shows one record no matter how many customers I enter.

Please help.

Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top