Combo box to automatically fill in values

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

How can I make a combo box show some values on a form. They do not have to
be stored anywhere, they are just for show. They will be from a cost list
table that has descriptions. I want it to show the descriptions in the empty
text boxes when I select a name of the cost from the cost list table.

I have tried to put a subform within a subform but it will not let me do
this with the view set to continuous forms.

Thanks
 
If you have more than one column of data in your combo box's definition, you
can use the combo box's AfterUpdate event to "put" them in additional
controls on your form. The code would look something like:

Me!txtYourDescriptionTextBox = Me!cboYourComboBox.Column(1)

The Column() property is zero-based, so the above example would take the
second column's entry from the chosen combo box row and put it in the
"description" text box.
 
Jeff,

I tried your suggestion but must have done something wrong. I got this error;

This error occurs when an event has failed to run because Microsoft Office
Access cannot evaluate the location of the logic for the event. For example,
if the OnOpen property of a form is set to =[Field], this error occurs
because Access expects a macro or event name to run when the event is fired.

This is my code;

=[Me]![AccountDesc]=[Me]![cboGLAccount].[Column](2)

Any suggestions would be greatly appreciated.

Thanks,

Barry
 
Where? Where are you putting this code?

Why two equals signs?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Barry said:
Jeff,

I tried your suggestion but must have done something wrong. I got this
error;

This error occurs when an event has failed to run because Microsoft Office
Access cannot evaluate the location of the logic for the event. For
example,
if the OnOpen property of a form is set to =[Field], this error occurs
because Access expects a macro or event name to run when the event is
fired.

This is my code;

=[Me]![AccountDesc]=[Me]![cboGLAccount].[Column](2)

Any suggestions would be greatly appreciated.

Thanks,

Barry

Jeff Boyce said:
If you have more than one column of data in your combo box's definition,
you
can use the combo box's AfterUpdate event to "put" them in additional
controls on your form. The code would look something like:

Me!txtYourDescriptionTextBox = Me!cboYourComboBox.Column(1)

The Column() property is zero-based, so the above example would take the
second column's entry from the chosen combo box row and put it in the
"description" text box.

--
Good luck

Jeff Boyce
<Access MVP>
 
Jeff,

The code is in the After Update of the cboGLAccount combo box.

The text box is unbound with a name of AccountDesc.

I changed the code to this;

Me!AccountDesc = Me!cboGLAccount.Column(2)

and got this error;

Microsoft Office Access can't find the object 'Me!AccountDesc =
Me!cboGLAccount.'

The two = signs came from the expression builder that I used the first time.

I know I am missing something obvious but I lack the experience to see it.

Sorry

Jeff Boyce said:
Where? Where are you putting this code?

Why two equals signs?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Barry said:
Jeff,

I tried your suggestion but must have done something wrong. I got this
error;

This error occurs when an event has failed to run because Microsoft Office
Access cannot evaluate the location of the logic for the event. For
example,
if the OnOpen property of a form is set to =[Field], this error occurs
because Access expects a macro or event name to run when the event is
fired.

This is my code;

=[Me]![AccountDesc]=[Me]![cboGLAccount].[Column](2)

Any suggestions would be greatly appreciated.

Thanks,

Barry

Jeff Boyce said:
If you have more than one column of data in your combo box's definition,
you
can use the combo box's AfterUpdate event to "put" them in additional
controls on your form. The code would look something like:

Me!txtYourDescriptionTextBox = Me!cboYourComboBox.Column(1)

The Column() property is zero-based, so the above example would take the
second column's entry from the chosen combo box row and put it in the
"description" text box.

--
Good luck

Jeff Boyce
<Access MVP>
 
Barry

The error message appears to be Access telling you it can't find something
the way you spelled it.

Try a little test ... instead of setting the textbox to the 3rd column of
the combobox, try setting it to something specific, like, say, "TEST". Use
the quotes.

Does that work? If so, try using a message box to "see" the value in the
3rd column of the combobox selection.

Note: based on the "names", I'm going to guess that you have BOTH a field
named AccountDesc and a textbox with the same name. There's a chance Access
is confused. Also try renaming the textbox, say "txtAccountDesc" and see if
using that makes a difference.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Barry said:
Jeff,

The code is in the After Update of the cboGLAccount combo box.

The text box is unbound with a name of AccountDesc.

I changed the code to this;

Me!AccountDesc = Me!cboGLAccount.Column(2)

and got this error;

Microsoft Office Access can't find the object 'Me!AccountDesc =
Me!cboGLAccount.'

The two = signs came from the expression builder that I used the first
time.

I know I am missing something obvious but I lack the experience to see it.

Sorry

Jeff Boyce said:
Where? Where are you putting this code?

Why two equals signs?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Barry said:
Jeff,

I tried your suggestion but must have done something wrong. I got this
error;

This error occurs when an event has failed to run because Microsoft
Office
Access cannot evaluate the location of the logic for the event. For
example,
if the OnOpen property of a form is set to =[Field], this error occurs
because Access expects a macro or event name to run when the event is
fired.

This is my code;

=[Me]![AccountDesc]=[Me]![cboGLAccount].[Column](2)

Any suggestions would be greatly appreciated.

Thanks,

Barry

:

If you have more than one column of data in your combo box's
definition,
you
can use the combo box's AfterUpdate event to "put" them in additional
controls on your form. The code would look something like:

Me!txtYourDescriptionTextBox = Me!cboYourComboBox.Column(1)

The Column() property is zero-based, so the above example would take
the
second column's entry from the chosen combo box row and put it in the
"description" text box.

--
Good luck

Jeff Boyce
<Access MVP>
 
Burg,

Were you able to get Jeff's suggestion to work?

I get the error mentioned above.

If you got it to work could you please reply to this with the code that you
implemented and were in the form it was placed.

Thanks,

Barry
 
Back
Top