Get default value from another table

C

Charlie

First time poster (have mercy:)

Entering new records in a form for table TourDetail and I want to pick up
the MaxPax (maximum number of passengers) from table TourMaster. First thing
on the TourDetail form is a combo box for selecting the tour (from
TourMaster). Once this is done I want MaxPax from TourMaster to populate the
MaxPax field on the form, and then the operator can change the MaxPax or
leave it as is.

TIA,
Charlie
 
K

Ken Snell [MVP]

You can use the AfterUpdate event of the combo box to get the max value and
then put it in the textbox.

Something like this, perhaps:

Private Sub ComboBoxName_AfterUpdate()
Me.TextBoxName.Value = DLookup("MaxPax", "TourMaster", _
"TourID =" & Me.ComboBoxName.Value)
End Sub
 
L

Larry Daugherty

Hi Charlie,

In the query for your unnamed tour selection combobox - I'll call it
cboTour - make sure that you return the tour name and the MaxPax value.
Then, in the AfterUpdate event of cboTour put in code something like this:
Me!MaxPax=Me!cboTour.column(1).

For what its worth, I'd get a copy of the Reddick naming convention and
follow it. You may already have it as an appendix in one of your 3rd party
Access books.

HTH
 
C

Charlie

Thanks....it works fine

Ken Snell said:
You can use the AfterUpdate event of the combo box to get the max value and
then put it in the textbox.

Something like this, perhaps:

Private Sub ComboBoxName_AfterUpdate()
Me.TextBoxName.Value = DLookup("MaxPax", "TourMaster", _
"TourID =" & Me.ComboBoxName.Value)
End Sub
 
Top