Auto populating a field based on selction of other field

kacey8

Registered User.
Local time
Today, 19:40
Joined
Jun 12, 2014
Messages
180
Hi,

I hope I can explain this if possible.

I (will have) a form which a user fills in to enter new data.

I have two fields,

"Branch" and "Branch ID" (Branch ID will not be on the form, just in the table)

Branch will be fed by a combo box with seven choices. I would like it so that when "Branch" is populated it autopopulates Branch ID with a code which relates to the branch, so for example

BRANCH BRANCH ID
Braintree BRA
Colchester COL

I hope that makes sense.
 
Wow.. Thanks for that. I am sure it would have... I did just use the following though.

Code:
Private Sub Branch_Change()
Select Case Branch.Text
 Case "Billericay"
 Me.BranchID = "BIL"
 Case "Braintree"
 Me.BranchID = "BRA"
 Case "Brentwood"
 Me.BranchID = "BRE"
 Case "Chelmsford"
 Me.BranchID = "CHE"
 Case "Colchester"
 Me.BranchID = "COL"
 Case "Great Dunmow"
 Me.BranchID = "DUN"
 Case "Havering"
 Me.BranchID = "HAV"
 End Select
End Sub
 
I strongly advice you not to use this method ! Try the autofill, that is simple easy, efficient and no maintenance work in future.

With the above, you constantly have to hard code all cases, less efficient in terms of coding and branching. Messy, and will need code updates when you add a new branch !

This is my opinion, but you are free to choose what you want ! Good luck.
 
Thanks. I will experiment with the Autofill.
 

Users who are viewing this thread

Back
Top Bottom