Combobox empty when form opened

H

Hanksor

I have a form with a combobox setup to find a record with combobox
selection. When the form is opened, all the fields have information from
the first record but the combobox is empty? Is there a way to populate the
combobox or have the form empty when opened then populate all fields after
the selection in the combobox? Any help will be appreciated.

Hanksor
 
M

Mark

By default, when a form opens, it opens to the first record in the
recordset. You can program the form to go to a new record when it opens, so
all of your fields are blank.
 
V

Van T. Dinh

Use the Form_Current Event to set the value to the value of the
corresponding Field of the current Record. This will show the current value
in the ComboBox.
 
J

John Webb via AccessMonster.com

I would do as Vin T. Dinh suggests, with one modification - to assign it to
the form load event.

If you assign the code to the current event, it will run every time the
record is changed, when in fact you only need it to run when the form is
initialised.

A minor thing really, but best not to invite bad habits - if it was a
lengthy routine needed instead, it would have added a considerable amount
of processing time to your end users - and nothing frustrates them more
than sitting there twiddling their thumbs.

Cheers

John Webb
 
V

Van T. Dinh

John

I was thinking of the case where the user move to another Record via the the
Record Navigation Bar also.

With Form_Load Event, the (unbound) ComboBox will retain the value that last
selected, not the (just-now-selected) Record.

Assigning a value to an unbound Control will probably take millisecond so
this won't be a problem. However, I agree that lengthy code should only be
run whenever needed.
 
J

John Webb via AccessMonster.com

Ah, I see.

If I provide my own navigation I tend to get rid of that damn record
selector, and prevent the mousehweel & pagedown/up keys from changing a
record - and therefore only ever need to set the combobox properties at the
form load event.

As I have said to another poster this morning, my apologies - I can see why
you would use your method now, but too little sleep and too much wine had
been in effect last night!

Cheers

John Webb
 
V

Van T. Dinh

Same here. I have just gone to re-union party (after 30 years - I am
ancient) and I offered to pay extra for the good Australian wine and the
bloody damned restaurant refused and only served "house" wine (no-name
brand).

I got drunk, nevertheless.

(Did I get the spelling correct? <g>)
 
V

Van T. Dinh

Me.YourComboBox = Me.CorrespondingField

in the Form_Current Event Procedure. CorrespondingField is the Field in the
Form's RecordSource that corresponds to the BoundColumn of YourComboBox.
 
J

John Webb via AccessMonster.com

Damn those cheap restaurants!

Thou you may consider yourself old, but heck - we are all getting there,
and as proved in this thread; the old and the cunning often out smart the
young and the quick!
 
H

Hanksor

Thanks!!!!
Van T. Dinh said:
Me.YourComboBox = Me.CorrespondingField

in the Form_Current Event Procedure. CorrespondingField is the Field in the
Form's RecordSource that corresponds to the BoundColumn of YourComboBox.
 

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

Top