Selecting an option to update another field

  • Thread starter Thread starter roadie_jack
  • Start date Start date
R

roadie_jack

Guest
Hello

I work for a telecommunications company and am creating a database to merge information into a letter to send out to customers. We offer a number of different tarriffs, which I would prefare in a drop down menu (which isn't a problem) but what I would like to do is when one of these values from the drop down menu is chosen in the form, for this to input default values into 3 other fields.

For example for the drop down list, we shall call the field "tarriff", 2 of the values in there are "Corperate" and "Standard" and the other three fields are called "local", "national" and "mobile". From the drop down list and Corperate is chosen I would like "2.4" to appear in the "Local" Field, "2.7" to appear in the "National" field and "17.5" to appear in the "Mobile" field.

Any help would be great.

Thanks

Jack
 
Say you have a combo box called:

cmbMyCombo

and you want "MyItem1" to change the value of the text box txtMyText to 2.7 then you BUILD an EVENT on the "After Update" event as such:

Code:
If cmbMyCombo.Value = "MyItem1" Then
  txtMyText = 2.7
End If

Im sure you can figure out the rest from there.
 
ReAn said:
Say you have a combo box called:

cmbMyCombo

and you want "MyItem1" to change the value of the text box txtMyText to 2.7 then you BUILD an EVENT on the "After Update" event as such:

Code:
If cmbMyCombo.Value = "MyItem1" Then
  txtMyText = 2.7
End If

Im sure you can figure out the rest from there.

Don't do it this way - for several reasons. Here are a couple:

1) You will litter your code with unnecessary If, Thens and Elses where they are not needed. Taking up processing time

2) What happens if the value 2.7 changes to 3.1 or 3.5 etc etc. Each time a value changes you will have to go into your code and reamend.
A good piece of code should not need to be revisited in this way.

Its far better to store your values at table level where they can be altered without re-programming. Look at amending the record source of your form so you can add fields from there which will give you the appropriate values once the combobox value is changed.

If you need any further help give us a shout.
 
Thank you very much for that, I've got the thing working now. I've got another query, but I'll create a new thread for that. Cheers
 

Users who are viewing this thread

Back
Top Bottom