A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

2 Related field or Auto fill up 2nd field after 1st field entered



 
 
Thread Tools Display Modes
  #1  
Old September 17th, 2006, 11:32 AM posted to microsoft.public.access.gettingstarted
Kaoli
external usenet poster
 
Posts: 1
Default 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  
Old September 17th, 2006, 11:40 AM posted to microsoft.public.access.gettingstarted
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:20 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.