nathan2314
01-13-2009, 09:08 AM
Hi All :hi:
I'm very new to VBA in Access. Basically all I want to do is set a text field in a form I have to a value based on another field in the form and then have that put in the underlying table.
So far I have a table created called 'OverseasConnections'. In this table, among other fields, I have two fields called 'Location' and 'Trigraph'. The field Location is linked to a table (called 'Countries') that has two fields. One is the country name and the other is the associated trigraph (for example: United States, USA etc..). The trigraph (ex USA..) is the primary key in this table. So in my form, the user can select from a drop down combo (labeled 'Location') to pick the country of interest. I would like the 'Trigraph' text box to automatically populate with the correspoding trigraph value. So if the user picked 'United States' from the 'Location' combo box, the 'Trigraph' text box should populate with 'USA'.
I built a query called qryTrigraph that uses the tables 'OverseasConnections' and 'Countries' and I pull in the values Countries.Trigraph and OverseasConnections.Location. I'm thinking if I somehow use VBA in the events section of the properties in the combo box 'Location' I should be able to automatically run this query and put the value in the 'Trigraph' text box. But I cant get it to work.
Appreciate any help!! :bow:
I know there are probably better ways of doing this.
I'm very new to VBA in Access. Basically all I want to do is set a text field in a form I have to a value based on another field in the form and then have that put in the underlying table.
So far I have a table created called 'OverseasConnections'. In this table, among other fields, I have two fields called 'Location' and 'Trigraph'. The field Location is linked to a table (called 'Countries') that has two fields. One is the country name and the other is the associated trigraph (for example: United States, USA etc..). The trigraph (ex USA..) is the primary key in this table. So in my form, the user can select from a drop down combo (labeled 'Location') to pick the country of interest. I would like the 'Trigraph' text box to automatically populate with the correspoding trigraph value. So if the user picked 'United States' from the 'Location' combo box, the 'Trigraph' text box should populate with 'USA'.
I built a query called qryTrigraph that uses the tables 'OverseasConnections' and 'Countries' and I pull in the values Countries.Trigraph and OverseasConnections.Location. I'm thinking if I somehow use VBA in the events section of the properties in the combo box 'Location' I should be able to automatically run this query and put the value in the 'Trigraph' text box. But I cant get it to work.
Appreciate any help!! :bow:
I know there are probably better ways of doing this.