Combo box to show previous value

S

str8actingboi

Hi all,

How can I make a combo box on an Access form display the value that
was entered into the same combo box on the previous record in the same
combo box.

Thanks.
 
R

Rob G

When you set the value from the combo box you can copy the value to an
unbound text box (which you can hide) or copy the value to a module with a
public global variable. I'd open up a module and create a public variable
with a couple get and set methods to control the access to the variable.

If you need some examples I can write them for you. Then what you do is tap
into one of the forms' events like "on current" you'd say:

....
Me.strTextBox1 = Nz(Module1.GetMyTextString(), "")
....

Then you'd have to remember to make sure the user saved the changed record
or undo (ESC) the record if you wanted to reverse the change back out.

If you use a hidden unbound text box to save the data, then you'll have to
manipulate the bound text box in the forms' code similar to the way I
described above.

I hope this helps.

Rob.
 
L

Linq Adams via AccessMonster.com

If the combobox is unbound (i.e. it's not bound to a field in your underlying
table) it should stay the same when moving to another record.

If it is bound to a field in your underlying record

Private Sub YourComboName_AfterUpdate()
YourComboName.DefaultValue = """" & Me.YourComboName.Value & """"
End Sub

will make it display it's value from the previous record, until you
physically change it or close the form.
 

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