Microsoft Access. Passing an ID/value to a subform. or between forms

0 pts.
Tags:
Development
E-business
Microsoft .NET
Programming Languages
SQL
VBA
VBScript
Visual Basic
Web development tools
Hello Everyone. I am using MS Access 2000 I have a form (frm_cboclient)that has a combobox on it that I populate by querying a client table for clientID and client name. What I would like to do then is have a subform that will display all my order infomration from my order table, where the clientID in the order table matches the clientID of the client name selected in the combobox. And if I select a different client from the combo box, have the orders in the subform change to reflect the newly selected clients orders. I don't think this is too difficult, I just don't know how to pass ID's or values to subforms, or how to pass values between forms. Any help is greatly appreiated. Thank You Gryphon.
ASKED: January 22, 2005  11:39 PM
UPDATED: February 2, 2005  3:44 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Assuming the combo box on frm_cboclient is named cboClient, set the subform’s recordsource to something like:

SELECT Orders.* FROM Orders WHERE Orders.ClientID = [Forms]![frm_cboclient]![cboclient]

Discuss This Question: 7  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Littlew
    You could also use the ClientID as the link criteria when you set up the subform i.e. set the Link Child Fields and Link Master Fields properties of the subform both to ClientID.
    0 pointsBadges:
    report
  • Gryphon
    Hi JTaylor4, LittleW, thank you for trying to help. I must be doing somethnig wrong, as when I enter ret to enter the refernce to the form I get an error stating that I am not using the proper method of refercencing forms. Also what does it mean that my form or control is unbound? could this be what is causing the problem?
    0 pointsBadges:
    report
  • JTaylor4
    If your form is unbound, that means you don't have a recordsource for it. If your control is unbound, that means you don't have a control source for it. If a control is unbound, changing the value of that control won't update any table values unless you do it with code.
    0 pointsBadges:
    report
  • Littlew
    Are you using the combo box to select which client record you want to look at? If you are, the easiest way to do this is to create a form based on the Client table (you can do this with the wizard if you want). If you already have a form, you can go into the properties (right click the box in the top left-hand corner to open form properties), click on the data tab and select the name of the client table where it says Record Source. Having something in the Record Source property means that your form is now bound. Next create a subform and base it on the table containing the subform data - let's call this table Sub for now. Hopefully you have a column in table Sub that is called ClientID or similar which contains the matching data. It should ask you which fields you want to match on. To select the records, now create a combo box on the main bit of the form based on the client table. Because your form is bound to a table, you should get another option something to the effect of 'find records based on a value I have selected'. You should then be able to select clients using this combo box and the corresponding records should be displayed in the subform. Once you have got this working, have a look at the properties under the data tab for the main form, sub form and sub form control to see how the information you have entered relates to the properties of these objects. :-)
    0 pointsBadges:
    report
  • VicWild
    In design view of your form click the subform and right click to display the 'Properties'. Under tab 'All' you will see section 'link child fields' and 'link master fields'. This will only work if you have both of your forms bound to a table. If you have not, for ease, I suggest you create a form using the wizard (using the table that contains the value you want to filter on). Create a combo box using the wizard and take option 3. Then create your subform (the one which will display your records) using the wizard and you will be prompted to enter the child and master fields. Have a look at this and if you need more help let me know.
    0 pointsBadges:
    report
  • VicWild
    In design view of your form click the subform and right click to display the 'Properties'. Under tab 'All' you will see section 'link child fields' and 'link master fields'. This will only work if you have both of your forms bound to a table. If you have not, for ease, I suggest you create a form using the wizard (using the table that contains the value you want to filter on). Create a combo box using the wizard and take option 3. Then create your subform (the one which will display your records) using the wizard and you will be prompted to enter the child and master fields. Have a look at this and if you need more help let me know.
    0 pointsBadges:
    report
  • Gryphon
    thanks everyone for your assistnace. I got what I wanted to work, using a slightly different approach. I used a combo box and a list box and populated them using queries, and then by passing in string variables I filter what shows in my list box based on what is selected from my combo box. Thanks again for everyones help. Much appreciated. Gryphon
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following