Combo Box Selection Remain Static Upon Adding New Record?

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

Guest

I have a form where the same input person may scan in many barcodes. Each barcode constitutes one record. Is there a way that the combobox that holds the input person's name can hold that value even when they are adding a new record? The value in the combo box should only change when the user changes it

Thank you!
 
Hi, Tina.

Sure; set the Default Value property in the AfterUpdate
event:

YourComboBoxName.DefaultValue = YourComboBoxName

HTH
Kevin Sprinkel
-----Original Message-----
I have a form where the same input person may scan in
many barcodes. Each barcode constitutes one record. Is
there a way that the combobox that holds the input
person's name can hold that value even when they are
adding a new record? The value in the combo box should
only change when the user changes it.
 
Tina,
Hmmm. No, when the After Update event of the combo box is
called, it knows its current value, and the code provided
should set the control's Default Value so that any
subsequent records have that value until you change it. I
think, then, that the Default Value is not being changed.
Check your syntax in the control reference. Did you
include Me! before the control name?

You can also test by entering form design view, showing
the Properties window, and returning to Form Display mode
with the Properties window still visible. Change the
Default Value manually (remember it is likely an integer
value corresponding to the PK representing the name, not
the name itself).

If this does not resolve the issue, please post the entire
code as you've entered it including the sub header and
footer, and provide more information on the form, e.g., is
it a main form and a subform or just a single form? If
the former, what are the Record Sources and how are they
linked?

KS
-----Original Message-----
Kevin,

I tried your suggestion and the form still clears out the
Input Employee field. Would I need to query for the last
record to find the Input Employee after the update?
 
Access doesn't know what "InputEmployee" means, you need
Me! in front of it also. Technically, what you're doing
is assigning the control's value of the current record
(the Value property) to the DefaultValue property. Since
Value is the default property of a combo box, you don't
need to refer to it explicitly. Either of the following
should work:

Me![InputEmployee].DefaultValue = Me![InputEmployee].Value

or

Me![InputEmployee].DefaultValue = Me![InputEmployee]

And, BTW, it was MY error not explicitly referencing the
form. Sorry for holding you up.

Best regards.
Kevin Sprinkel
 
Kevin

Still no luck. I'm still getting the #Name? error when trying to add the next new record. Any other thoughts? Thanks so much for all of your help!!

Tina
 
I just realized that although the default value being assigned is recognized in the properties window, a new record is not being created, so I think that's why I'm getting the #Name? error. If I enter any value in one of the fields, the record ID moves to the next record number (it's an autonumber primary key).
 
Tina,

The only thing I can think of is a possible name conflict
between your control and the bound field. To avoid these,
most developers rename all of their controls per a naming
convention--a prefix to id the control type followed by
its underlying field, e.g., cboInputEmployee.

Please try renaming your control. You'll also have to
alter your code so that all references to the old control
now refer to the new name. When I do this, I usually
create a new event procedure for the newly named control,
and cut and paste the body of the old procedure, then do a
search and replace.

If this isn't it, I'm out of ideas.

HTH
Kevin Sprinkel

-----Original Message-----
I just realized that although the default value being
assigned is recognized in the properties window, a new
record is not being created, so I think that's why I'm
getting the #Name? error. If I enter any value in one of
the fields, the record ID moves to the next record number
(it's an autonumber primary key).
 
Back
Top