PC Review


Reply
Thread Tools Rate Thread

How do I use a combo box to input data into two text boxes on a fo

 
 
Will_T
Guest
Posts: n/a
 
      6th Jul 2009

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.

--
Will
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      6th Jul 2009

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
http://I.Am/DougSteele
(no e-mails, please!)


"Will_T" <(E-Mail Removed)> wrote in message
news:35AE0F51-F7DD-46FB-85CA-(E-Mail Removed)...
>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.
>
> --
> Will



 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      6th Jul 2009
Something like this should do it for you:
Private Sub Combo1_AfterUpdate()
End Sub

In between these two lines of code, type the following:
Me!TextBoxName = Me!ComboName.Column(1)


Take a look at this:
http://www.datapigtechnologies.com/AccessMain.htm
You will probably learn a lot from those videos (several about ComboBoxes too)

HTH,
Ryan---
HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Douglas J. Steele" wrote:

> 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
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Will_T" <(E-Mail Removed)> wrote in message
> news:35AE0F51-F7DD-46FB-85CA-(E-Mail Removed)...
> >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.
> >
> > --
> > Will

>
>
>

 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      6th Jul 2009
Will_T wrote:
>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.



Add the hours field to the combo box's row source query and
change the combo box's properties as needed. Then you can
display the hors value in a text box by using an expression
like:
=thecombobox.Column(N)
where N is the 0 based number of the hours field in the
query.

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
Will_T
Guest
Posts: n/a
 
      6th Jul 2009

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


"Douglas J. Steele" wrote:

> 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
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Will_T" <(E-Mail Removed)> wrote in message
> news:35AE0F51-F7DD-46FB-85CA-(E-Mail Removed)...
> >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.
> >
> > --
> > Will

>
>
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      6th Jul 2009

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
http://I.Am/DougSteele
(no e-mails, please!)


"Will_T" <(E-Mail Removed)> wrote in message
news:1EADE8E8-6A52-44D5-A9CE-(E-Mail Removed)...
> 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
>
>
> "Douglas J. Steele" wrote:
>
>> 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
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "Will_T" <(E-Mail Removed)> wrote in message
>> news:35AE0F51-F7DD-46FB-85CA-(E-Mail Removed)...
>> >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.
>> >
>> > --
>> > Will

>>
>>
>>



 
Reply With Quote
 
Will_T
Guest
Posts: n/a
 
      6th Jul 2009

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


"Douglas J. Steele" wrote:

> 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
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Will_T" <(E-Mail Removed)> wrote in message
> news:1EADE8E8-6A52-44D5-A9CE-(E-Mail Removed)...
> > 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
> >
> >
> > "Douglas J. Steele" wrote:
> >
> >> 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
> >> http://I.Am/DougSteele
> >> (no e-mails, please!)
> >>
> >>
> >> "Will_T" <(E-Mail Removed)> wrote in message
> >> news:35AE0F51-F7DD-46FB-85CA-(E-Mail Removed)...
> >> >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.
> >> >
> >> > --
> >> > Will
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      6th Jul 2009

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
http://I.Am/DougSteele
(no e-mails, please!)


"Will_T" <(E-Mail Removed)> wrote in message
news:73A4BF57-D16D-4C74-A857-(E-Mail Removed)...
>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
>
>
> "Douglas J. Steele" wrote:
>
>> 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
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "Will_T" <(E-Mail Removed)> wrote in message
>> news:1EADE8E8-6A52-44D5-A9CE-(E-Mail Removed)...
>> > 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
>> >
>> >
>> > "Douglas J. Steele" wrote:
>> >
>> >> 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
>> >> http://I.Am/DougSteele
>> >> (no e-mails, please!)
>> >>
>> >>
>> >> "Will_T" <(E-Mail Removed)> wrote in message
>> >> news:35AE0F51-F7DD-46FB-85CA-(E-Mail Removed)...
>> >> >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.
>> >> >
>> >> > --
>> >> > Will
>> >>
>> >>
>> >>

>>
>>
>>



 
Reply With Quote
 
Will_T
Guest
Posts: n/a
 
      6th Jul 2009

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


"Douglas J. Steele" wrote:

> 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
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Will_T" <(E-Mail Removed)> wrote in message
> news:73A4BF57-D16D-4C74-A857-(E-Mail Removed)...
> >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
> >
> >
> > "Douglas J. Steele" wrote:
> >
> >> 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
> >> http://I.Am/DougSteele
> >> (no e-mails, please!)
> >>
> >>
> >> "Will_T" <(E-Mail Removed)> wrote in message
> >> news:1EADE8E8-6A52-44D5-A9CE-(E-Mail Removed)...
> >> > 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
> >> >
> >> >
> >> > "Douglas J. Steele" wrote:
> >> >
> >> >> 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
> >> >> http://I.Am/DougSteele
> >> >> (no e-mails, please!)
> >> >>
> >> >>
> >> >> "Will_T" <(E-Mail Removed)> wrote in message
> >> >> news:35AE0F51-F7DD-46FB-85CA-(E-Mail Removed)...
> >> >> >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.
> >> >> >
> >> >> > --
> >> >> > Will
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Will_T
Guest
Posts: n/a
 
      6th Jul 2009
I added a watch to it and the value says it is "Out of context".
--
Will


"Douglas J. Steele" wrote:

> 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
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Will_T" <(E-Mail Removed)> wrote in message
> news:73A4BF57-D16D-4C74-A857-(E-Mail Removed)...
> >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
> >
> >
> > "Douglas J. Steele" wrote:
> >
> >> 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
> >> http://I.Am/DougSteele
> >> (no e-mails, please!)
> >>
> >>
> >> "Will_T" <(E-Mail Removed)> wrote in message
> >> news:1EADE8E8-6A52-44D5-A9CE-(E-Mail Removed)...
> >> > 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
> >> >
> >> >
> >> > "Douglas J. Steele" wrote:
> >> >
> >> >> 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
> >> >> http://I.Am/DougSteele
> >> >> (no e-mails, please!)
> >> >>
> >> >>
> >> >> "Will_T" <(E-Mail Removed)> wrote in message
> >> >> news:35AE0F51-F7DD-46FB-85CA-(E-Mail Removed)...
> >> >> >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.
> >> >> >
> >> >> > --
> >> >> > Will
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using comand buttons to input data into text boxes Nick T Microsoft Access 3 13th May 2008 10:03 PM
Prevent manual text input in combo boxes =?Utf-8?B?TmlscyBQZXR0ZXJzc29u?= Microsoft Access Forms 4 27th Mar 2006 02:39 PM
Prevent manual text input in combo boxes =?Utf-8?B?TmlscyBQZXR0ZXJzc29u?= Microsoft Access Database Table Design 4 27th Mar 2006 02:39 PM
How to input different data in combo / check boxes for datasheets =?Utf-8?B?QmVsaW5kYSBDb3g=?= Microsoft Access Getting Started 3 23rd Jan 2006 02:09 AM
Clear data in text boxes / combo boxes =?Utf-8?B?Q2hyaXM=?= Microsoft Access 4 31st May 2005 08:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:48 PM.