Yes, setting the ControlSource to something like that means the text box is
no longer bound, so values won't be saved. However, if the value's available
elsewhere, you shouldn't really need to save it anyhow: you can always get
it from the original source.
Afraid I have no idea why the code isn't working. As you say, it's a simple
solution, so there's (usually) no place for it to go wrong! One thought:
what version of Access are you using? If Access 2007, is the database in a
Trusted Location? (When you open the database, is there a message under the
ribbon saying that code has been disabled?)
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
Will_T said:
I change the ControlSource of the hours text box to =cboCourse.Column(1)
and
now it will show up in the hours text box. If I do that it should not
write
to the table because its now longer bound to the field Hours?
Where I am going wrong?
--
Will
Will_T said:
I select the course manually from the combo box. Based on that click in
the
course combo box I was hoping that the code would automatically fill in
the
hours text box.
The combo box will display both fields.
When I select the course name from the course combo box it will fill in
that
box but it will not fill in the hours text box.
Your solution seemed simple enough so it must be some property that I
have
not set correctly in the form of the object. I am lost on what it could
be.
--
Will
:
How are you selecting something from the combo box: manually or through
code? It'll only work if you're selecting it manually.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
I put a Msgbox command into the code and it does not appear. So the
code
is
not running. What would stop it from running?
--
Will
:
Put a break point in it (so that the code stops when it runs), or
temporarily put a message box into the code.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
I am not certain that it firing but the Event Procedure is set to
the
AfterUpdate property.
How can I check to see if the Event Procedure is firing or how can
I
insure
that it will fire?
--
Will
:
Are you certain that the AfterUpdate event is firing? Is the
AfterUpdate
property set to [Event Procedure]? If you click on the ellipsis
(...)
to
the
right of the property, are you taken into the VB Editor in the
midst
of
that
code?
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Thanks, but it's not working for me. It's not entering the
data
into
the
other text box. I must be doing something wrong.
The name of combo box is Course and the name of the other text
box
is
Hours.
The combo box's row source is a table that has two fields
Course and
Hours.
The combo box will display both fields. When I select the
correct
Course
on
the combo box the Hours text box never changes. I have a
default
value
for
Hours, it is 0.
I am using the combo's AfterUpdate value. Here is what I have;
Private Sub Course_AfterUpdate()
Me!Hours = Me!Course.Column(1)
End Sub
--
Will
:
Assuming that the additional pieces of information are
contained in
the
RowSource of the combo box, you can put code in the
AfterUpdate
event
to
do
that.
For instance, the following will take the value from the
second
column
of
the selected row in the combo box into a text box (the Column
collection
starts numbering at 0)
Private Sub MyCombo_AfterUpdate()
Me!SomeTextbox = Me!MyCombo.Column(1)
End Sub
Note that the ColumnCount property of the combo box must be at
least
as
big
so as to include the column being referenced. However, it's
not
necessary
that the column be visible in the combo box (you can control
this
through
the ColumnWidths property)
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
I have created a combo box that inputs data from a lookup
table
into
the
current text box on a form. I would like it to add the
related
data
of
another field to the other text box on the form.
For example; the user selects the appropriate course from
the
combo
box
which will then input the course and hours into the
cooresponding
text
boxes
on the form.