Need help with a list and subform

Decosta

New member
Local time
Today, 07:19
Joined
Jun 19, 2001
Messages
5
http://www.geocities.com/skye1228/access.jpg

As you can see in the above page,the list box and the combo box are linked(i.e When Beer is selected, the list box shows the list of beers available).

I want to be able to click on an item in the list box(Beamish) and have it appear in the Billing Subform with its price showing.I want to be able to do this via the command buttons shown.

I've tried to look up examples,but no luck.
 
Alright, well the link above isn't working, but I think I understand what you are trying to do. Put the following code in your command button's OnClick event when you want to see the item in the subform.

Me!SubForm_Name.Form.Filter = "[BeerName]='" & me!ComboBoxName & "'"
Me!SubForm_Name.Form.FilterOn = True

Notice I added the ticks in the filter('). I'm assuming you are using a string for the Beer Name. If you are using a number to refer to it, take out the ticks. Also, change BeerName to whatever the field is that contains the name of the beer to be looked up.

You could also set the recordsource of the subform equal to a SQL statement, like so..

MySQL = "SELECT * FROM BeerTable WHERE BeerName='" & me!ComboBoxName & "'"
Me!SubForm_Name.Form.recordsource = MySQL

Again, I used the ticks, so take them out if it's a number value. Hope one of these two suggestions helps you out.

Doug
 
When I put the code onto the button, a record appears to be added to the subform, but I can't see it.

what exactly does the code do?
 
Well, depending on which one you used they do seperate things... I would suggest using the second one which is the SQL approach. What that code does is set the recordsource of the form to your beer table and only lists the data on the beer that you selected. It's similar to selected a specific table as the source of your form, when you create a new form and the dialog box comes up with the combobox at the bottom. Everytime you change the beer and hit the command button, it will change the info in the subform. I hope that answers your question.

Doug
 

Users who are viewing this thread

Back
Top Bottom