Problem with ComboBox

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

Guest

I need help with a problem that I didn't imagined it could occur. It's kinda
tough to explain it but i'll try...
I have a Form with a ComboBox made with the Wizard help, where I got the
values I wanted from a Table.
This Form contains also a Button that runs a VBA code. Every time I click
this button and close the Form, my selected value in the ComboBox becomes the
first field in the Table wich I imported the values to select from. How can I
mantain my Table intact and continue to use this ComboBox normally? Does
anyone faced a similar problem?
 
Sounds like the combo is bound to a field in your table, and you want it
unbound.

Open the form in design view.
Right-click the combo, and choose Properties.
On the Data tab of the Properties box, delete the field name beside:
Control Source
 
That's a negative Mr. Browne. My Combo is already unbound... although when I
created this Combo with values from a table, I imported 8 columns of that
table and I have some TextBoxes that alter their values according to the
expression "=ComboBox.Columns(1)","=ComboBox.Columns(2)",...
Could this be the problem?
 
So the combo has nothing in its ControlSource property, but when you open
the form it has a value?

You may need to clear its Default Value property.

If that does not work either, then there must be some code in one of the
events that is assigning a value to the combo.

The text boxes referring to the combo's Column property are fine. They will
not give the combo a value.
 
The Default Value was already cleared also... in my VBA code, wich I execute
every time the user clicks a button on the form, doesn't seen to have
anything that assigns a value to the Combo... the only thing I do related to
it is the following:
Dim X as String

With Form
If .Combo.Text = "" Then
MsgBox "Warning!"
Exit Sub
End If
.Combo.SetFocus
X = .Combo.Text
End With

Any clues?
 
I've finally found out what was wrong in the code!
I named my variable with the same name as the Table Field the Combo Box was
looking values into. Guess the real problem there is that all the automation
is based on a 'dbs' variable set to the CurrentDB.
To solve it, I simply changed my variable name in the code...
Simple solution to a brainstorming puzzle.
 
Great. Solved.

Another interesting example of where VBA lets you be too sloppy, and
ambiguous names do bite you.
 
Back
Top