What kind of query can get the following result please? (1 Viewer)

Jordan76

Registered User.
Local time
Today, 11:56
Joined
Dec 26, 2002
Messages
49
I have 2 destination Tables:

The table looks like:

Code Airport1 Airport2 Airport3 Airport4 Airport5
AP1 $ $ $ $ $
AP2 $ $ $ $ $
AP3 $ $ $ $ $
AP4 $ $ $ $ $
AP5 $ $ $ $ $


On my invoicing form, I have 1 Text Box for Destination = txtDestination. And one for departure, txtdeparture.

I cant figure out how to have the query Prompt for Destination (the values under the code heading) and Departure (the headers beside the code header)

So Far by using a parameter Query I can get 1 full record of prices, but I need the query to isolate the specific destination price from where the passenger is departing from.

I need to be able to get a result such as this:

Code Airport3
AP2 $

So I need the headings to have a parameter too, is this possible from one table?

Thanks in Advance
Jordan
 

Jon K

Registered User.
Local time
Today, 11:56
Joined
May 22, 2002
Messages
2,209
Replace the text boxes for destination and departure with two combo boxes. Name them as cboDestination and cboDeparture.

Put a text box on the form for the price and name it as txtPrice.


Put the following code in the On Change event of cboDestination (using the correct name of the "DestinationTable" in the DLookup() function):-
________________________________
Private Sub cboDestination_Change()

If IsNull(Me.cboDeparture) Then
Me.cboDeparture.SetFocus
Exit Sub
End If

If IsNull(Me.cboDestination) Then
Me.cboDestination.SetFocus
Exit Sub
End If

Me.txtPrice = DLookup(Me.cboDeparture, "DestinationTable", _
"Code='" & Me.cboDestination & "'")

End Sub
----------------------------------

Put the same code in the On Change event of cboDeparture.


When the destination and departure are selected from the combo boxes, the price will be placed in txtPrice.
 

Jordan76

Registered User.
Local time
Today, 11:56
Joined
Dec 26, 2002
Messages
49
Thank you so very Much, not only have you helped me considerably you have shown me a method i never knew before. Thank you again.

Sincerely,
Jordan
 

Users who are viewing this thread

Top Bottom