data does not get carried over for combo-box.

L

Linda

I have the following routine in my OnCurrent Event of my
form. The purpose of this routine is to carry over the
data that was previously entered into the fields
txtHotel and cbocontrol_offcicer to a new record.
This work fine for my textbox named txthotel, for my
combo box named cbocontrol_officer it does NOT work.
I really don't see why it does not work for a combo-box.

Dim vHotel As String
Dim vContOfficer As Variant

If Me.NewRecord Then
Me![txtHotel] = vHotel
Me![cbocontrol_officer] = vContOfficer
End If

vHotel = Me![txtHotel]
vContOfficer = Me![cbocontrol_officer]

TIA.
 
W

Wayne Morgan

Just going by the code you've shown, I don't know why either one of them
would work. The values of the variables will be forgotten when the procedure
ends. To keep the value until the next time the procedure runs, you need to
use Static instead of Dim. Another option is to set the controls' Default
Value property. This value will automatically be filled in then when you
move to a new record and will save having to remember the value in a Static
variable.
 

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