Question:
Micorsoft Access Help. How do I automatically fill a field from a combo box?
roo_mccarthy
2012-05-25 15:15:31 UTC
I am building a database for a summer camp.

I have a table [Tours] with 3 columns ( ID, Tour Name, Tour Price ) and 5 rows (List of Tours)

I have a form that allows you to choose the tour from a combo box.

My question is, How do I get another field to automatically fill in with the tour price, after I have selected the tour using the combo box?

Thanks in advance!

(After that I will add the price of the tour onto the registration fee so it will read [Registration Fee] + [Tour Price] = Total Payable)

((Sorry if its a silly question, for some people it will probably be really easy))

(((Syntax formulas would be great)))
Three answers:
ray_diator
2012-05-25 15:29:08 UTC
SOme things do not make sense, for instance your Table Tours contains a field called Tour Price but you want a combo box to automatically enter the date for that field based on the tour. Is the Tour Name and the tour the same thing?



Which table contains Registration Fee?



Total Payable will appear in a query or report - not in a table



In a query you will make a new column



Total Payable: = [Registration Fee] + [Tour Price]
Andrew L
2012-05-26 00:52:49 UTC
It's much easier to use the Combo box wizard, which walks you through the process of designing a combo box, to find a record based on the entry selected.



Go to form design. In the combo box properties, it should have two columns. The first column is your ID which has zero length, and the second column is your tour name which can have any length you choose. The bound column should show 1. The "After update" event of the combo box will have some such code as



Dim rs As Object

' find the first record which matches the ID.

Set rs = Me.Recordset.Clone

rs.FindFirst "[Id] = " & Str(Nz(Me![cboSrch], 0))



' where [cboSrch] is the name of your combo box.



Your form will have textboxes to display other fields, which will populate automatically when you update the combo box.
anonymous
2016-10-19 05:12:13 UTC
permit me see if I understand you - you like a single combobox to exhibit the particularly names of the fields (columns) ? if so, i think of the only way you're able to desire to try this would be to circulate into the VBA code at the back of, and retrieve the names of the fields (employing DAO or ADO), then manually upload them to the combobox. Now, apparently such as you're able to correctly be relating actually values interior the fields. If no longer, i don't understand why you're able to desire to chenge the names of the fields interior the table (?) extra data could be helpful.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...