If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
2 Related field or Auto fill up 2nd field after 1st field entered
I have 2 related field in a transaction table
Example "Taxi Number" (1st Field) "Taxi Driver" (2nd Field) Let say i have a table having latest or default Driver driving which taxi record as per below TaxiNumber TaxiDriver New York 1111 Micheal New York 2222 Jodan ..... Now if i entred New York 1111 into "Taxi Number" (1st Field) in the transaction table can "Taxi Driver" (2nd Field) auto filling with Micheal into the field? but i still able to change "Taxi Driver" (2nd Field) as Jadan or other driver because maybe today he taking leave and replace by other driver. TaxiNumber TaxiDriver New York 1111 (after entered) Micheal (auto filled but still able to change to other driver) |
#2
|
|||
|
|||
2 Related field or Auto fill up 2nd field after 1st field entered
How are you entering the taxi number?
If you're using a combo box (which would be the preferred approach), make sure that the combo box also contains the driver name, even if it isn't displayed. In the AfterUpdate event of the combo box, put code like: Private Sub cboTaxiNumber_AfterUpdate() Me.txtTaxiDriver = Me.cboTaxiNumber.Column(1) End Sub This assumes that the driver name is the 2nd column in the combo box (the Column collection starts numbering at 0) If you're using a text box, you'll need to do a look-up in the AfterUpdate event. You should be able to use something like: Private Sub txtTaxiNumber_AfterUpdate Me.txtTaxiDrive = DLookup("[TaxiDriver]", "[Drivers]", "[TaxiNumber] = '" & Me.txtTaxiNumber & "'") End Sub cboTaxiNumber is supposed to be the name of the combo box being used if that's the route you're going while txtTaxiNumber would be the name of the text box you key the taxi number into if using that route. txtTaxiDriver is the text box to hold the driver name. I've assumed that the data is stored in a table named Drivers, and that the relevant fields in that table are TaxiNumber and TaxiDriver. Replace those names with whatever your actual names are. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "Kaoli" Kaoli @discussions.microsoft.com wrote in message ... I have 2 related field in a transaction table Example "Taxi Number" (1st Field) "Taxi Driver" (2nd Field) Let say i have a table having latest or default Driver driving which taxi record as per below TaxiNumber TaxiDriver New York 1111 Micheal New York 2222 Jodan .... Now if i entred New York 1111 into "Taxi Number" (1st Field) in the transaction table can "Taxi Driver" (2nd Field) auto filling with Micheal into the field? but i still able to change "Taxi Driver" (2nd Field) as Jadan or other driver because maybe today he taking leave and replace by other driver. TaxiNumber TaxiDriver New York 1111 (after entered) Micheal (auto filled but still able to change to other driver) |
Thread Tools | |
Display Modes | |
|
|