VB error message....

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

Guest

Hi all,

I'm getting a runtime error message everytime I try to enter data in my
form. I have a combo box in my form and right beside it I have a text box,
and in that textbox I want a value from the combobox to appear when I select
a value from the combo box. ex. the combobox has the info on trades such as
carpentry, electricians, plumbers, etc. and before the trades are the trade
numbers, after the trades are the trade types, designated, non-designated.
Now, what I want my form to do is when I choose a trade number from the
combobox, I want the trade name and trade type to appear in two separate
textboxes beside the combobox.

For starters, I have the code:

textbox32=combo30.column(2)
textbox36=combo30.column(3)

this code keeps giving a runtime error.

Any suggestions??
 
"I have a pain, Doctor. What do I do to make it stop?"

What is the error number and description?
On which line of code does it occur?
 
I put the code in the "After Update" line. The error message is "Run-Time
error'-2147352567(80020009):"
 
If I had to guess (which, of course, I do <g>), I'd say he's only got 3
columns in the combo box, and that he should use

textbox32=combo30.column(1)
textbox36=combo30.column(2)

since the Column collection starts numbering at 0, not 1.
 
Taht doesn't give much info. That is a low level error. I am not sure, but
it may be you are referencing your combo columns incorrectly. Access can
fool you on that one. When you indentify the bound column as 1, it is in
fact, the first column; however, the index to the column collection is zero
based, so in VBA, the first column is referenced as column(0), column(1)
would be the second column.
Also, to avoid confusing Access, qualify your control references:

Good:
Me.textbox32 = Me.combo30.column(2)
Me.textbox36 = Me.combo30.column(3)

Better:
With Me
.textbox32 = .combo30.column(2)
.textbox36 = .combo30.column(3)
End With

Best:
With Me
.txtTradeNbr = .cboTrades.column(2)
.txtTradeType = .cboTrades.column(3)
End With

Using descriptive names rather than the generic names provided by Access
makes your code much easier to read. Using With also reduces code and
executes faster.
 

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

Back
Top