data does not get carried over for combo-box.

  • Thread starter Thread starter Linda
  • Start date Start date
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.
 
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.
 
Back
Top