Carrying over value to a new record

  • Thread starter Thread starter Amit
  • Start date Start date
A

Amit

Hi,

I would like to carry over the value of a combobox from
the current record to the next/new record and be the
default value.

In the AfterUpdate event of the combobox, I have the code:

Me.[cbobox].DefaultValue = Me.[cbobox]

Also, in the close event of the form, I have the code:
Me.[cbobox].DefaultValue = ""

This is working fine when I open the form directly. But,
when the form is opened through another form using a
button, and the [cbobox] value is passed to it from the
original form, then this doesn't work. Is it because the
AfterUpdate for the cbobox is not firing in the instance
when the form is opened through another form? Where would
I place the code to make it work in both instances?

Thanks!

-Amit
 
Hi,


Properties are maintained by form-object. Each form-object get its own
set of controls and its own properties. They just share the code in common
(that is why ME refer to the exact set of data, when the code is running,
since there is just one sample of the code, the code has to know on which
set of data it should operate).

The new form-object is just not aware of the modification brought to the
"properties" of another of its brothers, since the object is a brand new
one. The most elegant way would be to pass the default value after the
creation of the form-object. I assume you use something like:



Dim f As Form_FormName

Set f = new Form_FormName
f.ControlName.DefaultValue = """" & Me.ComboBoxName & """"
f.Visible = true

On Error ... ' an error may not turn f visibility off ... be
prepare then
' to break the following loop if such an
error occur

Do Until Not f.Visible
DoEvents
Loop

.... recuperate data from f, if required...

Set f = Nothing



And the form-object f has to turn its visibility off (
Me.Visible=False )



Hoping it may help,
Vanderghast, Access MVP
 
Back
Top