Updating Two Text Boxes Based on Information Entered into a Third Text Box

D

DoveArrow

I feel a little silly, but I'm just going to come out straight and say
it: I play Dungeons & Dragons and I thought that it might be fun to
try and build a character sheet database at home so that I could play
around with some of the program's features and learn more about
Access. Unfortunately, I'm running into a snag. Here's my problem:

I have a form which updates a table, called 'Characters Table.' What I
want to be able to do is select a race from a second table, called
'Races Table,' using a combo box. Then, based on the race selected, I
want to have two text boxes update with some numbers called racial
modifiers. Example: If I select gnome as my race, it will populate the
[ConRacial] text box with a 2 and the [StrRacial] text box with a -2.
These text boxes will also update corresponding fields on my
Characters Table.

So far, I have everything figured out except for how to update the
racial modifier text boxes on my form once the race has been selected.
Is there a way to do this using an AfterUpdate event of some kind?

Please keep in mind that I am very new at this (I just learned how to
use Select Case statements like two days ago, and these were my first
ventures into using the VBA Code Builder features of Access), so
you'll need to speak slowly and patronizingly in a way that a total
amateur can appreciate and understand. Thanks.
 
M

Marshall Barton

DoveArrow said:
I feel a little silly, but I'm just going to come out straight and say
it: I play Dungeons & Dragons and I thought that it might be fun to
try and build a character sheet database at home so that I could play
around with some of the program's features and learn more about
Access. Unfortunately, I'm running into a snag. Here's my problem:

I have a form which updates a table, called 'Characters Table.' What I
want to be able to do is select a race from a second table, called
'Races Table,' using a combo box. Then, based on the race selected, I
want to have two text boxes update with some numbers called racial
modifiers. Example: If I select gnome as my race, it will populate the
[ConRacial] text box with a 2 and the [StrRacial] text box with a -2.
These text boxes will also update corresponding fields on my
Characters Table.

So far, I have everything figured out except for how to update the
racial modifier text boxes on my form once the race has been selected.
Is there a way to do this using an AfterUpdate event of some kind?


Sounds like fun ;-)

First, set the combo box's RowSource to a query that
includes the three fields Race, ConRacial and StrRacial. Be
sure that the combo box's ColumnCount property is set to 3.

Now, if you do not need to modify the racial modifier text
boxes after selecting a race in the combo box, then you can
do it with text box espressions like:

=combobox.Column(1)

If you do need to change the value later, then you need to
use code in the combo box's AfterUpdate event procedure:

Me.ConRacial = Me.combobox.Column(1)
Me.StrRacial = Me.combobox.Column(2)
 
D

DoveArrow

DoveArrow said:
I feel a little silly, but I'm just going to come out straight and say
it: I play Dungeons & Dragons and I thought that it might be fun to
try and build a character sheet database at home so that I could play
around with some of the program's features and learn more about
Access. Unfortunately, I'm running into a snag. Here's my problem:
I have a form which updates a table, called 'Characters Table.' What I
want to be able to do is select a race from a second table, called
'Races Table,' using a combo box. Then, based on the race selected, I
want to have two text boxes update with some numbers called racial
modifiers. Example: If I select gnome as my race, it will populate the
[ConRacial] text box with a 2 and the [StrRacial] text box with a -2.
These text boxes will also update corresponding fields on my
Characters Table.
So far, I have everything figured out except for how to update the
racial modifier text boxes on my form once the race has been selected.
Is there a way to do this using an AfterUpdate event of some kind?

Sounds like fun ;-)

First, set the combo box's RowSource to a query that
includes the three fields Race, ConRacial and StrRacial. Be
sure that the combo box's ColumnCount property is set to 3.

Now, if you do not need to modify the racial modifier text
boxes after selecting a race in the combo box, then you can
do it with text box espressions like:

=combobox.Column(1)

If you do need to change the value later, then you need to
use code in the combo box's AfterUpdate event procedure:

Me.ConRacial = Me.combobox.Column(1)
Me.StrRacial = Me.combobox.Column(2)

--
Marsh
MVP [MS Access]- Hide quoted text -

- Show quoted text -

I just have to say... THAT IS SO COOL!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top