Changing Default in Combo Box

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

Guest

This one is probably tougher to explain than to solve!

cmbVendor lists all vendors
cmbGLDesc is a combination of General Ledger codes and their descriptions
(two separate fields combined through a query for display purposes).

The Vendor table contains the GL Code, and once the Vendor has been
selected, I want the cmbGLDesc combo box to show that particular vendor's GL
code & Description.

I've gotten code written to the point where I get the combined GL Code &
Description, but can't get it to display in the cmbGLDesc box as the default
value.

Code I've already attempted is:

cmbGLDesc.Value = rec("FULLGL")

-- and --

cmbGLDesc.DefaultValue = rec("FULLGL")

-- and I've even tried --

With Me.cmbGLDesc
.DefaultValue = rec("FULLGL")
End With

(and .Value of course).

None get the combo box to display the default value.......all they display
is blanks....Oh, and if it matters, I still need to be able to have the user
override the default.

Thank you for your patience with me!
 
Roy,

The Default Value is not applicable here, as this only means anything at
the point where a new record is being started.

I can't imagine what rec("FULLGL") refers to... are you sure it is
returning a value which is included in the bound column of the
combobox's row source? If so, then I would expect this to work...
Me.cmbGLDesc = rec("FULLGL")
.... on the After Update event of the cmbVendor.
 
Sorry about that - I knew I would leave information out. The GL Code is
simply the account number, i.e., 5510, 5520, 5730, for the accountants. The
FULLGL is the entire name - "5560 - Office Supplies".

I inserted your line of code into the VBA segment for cmbVendor_AfterUpdate
and in Debug, saw that "Me.cmbGLDesc = rec("FULLGL")" supplied and received
the expected value, but still nothing shows in the cmbGLDesc box on the form.
 
Roy,

roy_ware said:
Sorry about that - I knew I would leave information out. The GL Code is
simply the account number, i.e., 5510, 5520, 5730, for the accountants. The
FULLGL is the entire name - "5560 - Office Supplies".

That's not really what I was wondering about... What's rec() all about?
 
Roy,

Well, leaving aside for the moment the question of whether this should
be getting stored in a table in the first place (it almost certainly
shouldn't!)... I can't think of a explanation for this. I have tried to
reproduce your situation here, and it works ok for me. If you are
interested in experimenting a little, you could try a couple of things
and see if it makes any difference:

1. Put a line of code
Me.cmbGLDesc.SetFocus
either before or after the line
Me.cmbGLDesc = rec("FULLGL")

2. Change the name of the cmbGLDesc combobox to the same as the name of
the table field it is bound to, and modify the code accordingly.
 
I gave up, deleted the form, and then rebuilt it, using the line of code you
suggested - and it works great! I must have had something screwy set in
there.

Thanks for all your help!
 
Back
Top