REPOST - Re: Using Default Value on Subform

J

jo

Marsh,

I changed my default value to Parent.CompanyName, etc. It
copies the info to the subform. I tried the me.recalc on
my subform enter event but it still doesn't record the
data in the subform table. If I click in the first field
of the subform (ShipLocName and begin re-typing the data
(I'm trying to not have to retype data), only then does
the autonumber get assigned to the record.

Is there something else I need to include with my
me.recalc?

-----------------------------------
jo said:
I have a Company form which includes the CompanyName,
CompanyAddress, CompanyCity, CompanySt, CompanyCountry.
Within this form is a nested ShipLoc Form which contains
similar information as above: ShipLocName, ShipLocAddress,
etc. I'm using tables from our existing order entry
system which requires that every company entry must have a
corresponding shiplocation. I know it sounds redundant,
but it was created many years ago.

I'm trying to make it easier for the user so they don't
have to retype information when entering a prospect. Once
it is entered in the Company form, I want the exact same
information to show up in the ShipLoc Form (at times,
there may only be a street address change). I'm currently
using the "default value" property for each field on on my
ShipLoc form and inserting: =[Forms]![Company]!
[CompanyName] and changing the corresponding field name
respectively.

Unfortunately, due to my inexperience at VB, when entering
a new company or prospect, the data in the ShipLoc Form is
not being inserted in the ShipLoc Table.


It seems that the default value property is determined
before you get to the subform and it's not reset in sync
with what's happening on the main form.

The thing that appears to work for me is to use the subform
Control's Enter event to execute:
Me.Recalc

BTW, it may be a little better to set the DefaultValue
property to:
Parent.CompanyName

instead of
Forms!Company!CompanyName

and, AFAICT, there is no need to use an = sign with this.
 
M

Michel Walsh

Hi,


I don't understand the whole story, but using Recalc after having
modified the Default value seems two different elements that should have not
come mixed. A DEFAULT value is only involved at the moment a record is
created. If your code runs, the record is already created, the DEFAULT value
won't come in play for the actual record. A default value does NOT mean
replace a NULL with something, it just implied to supply a value in a field
at the moment the record was created. If you want to change an value in the
actual control, in a bound form, change the control value bound to that
field to be modified.


Hoping it may help,
Vanderghast, Access MVP



jo said:
Marsh,

I changed my default value to Parent.CompanyName, etc. It
copies the info to the subform. I tried the me.recalc on
my subform enter event but it still doesn't record the
data in the subform table. If I click in the first field
of the subform (ShipLocName and begin re-typing the data
(I'm trying to not have to retype data), only then does
the autonumber get assigned to the record.

Is there something else I need to include with my
me.recalc?

-----------------------------------
jo said:
I have a Company form which includes the CompanyName,
CompanyAddress, CompanyCity, CompanySt, CompanyCountry.
Within this form is a nested ShipLoc Form which contains
similar information as above: ShipLocName, ShipLocAddress,
etc. I'm using tables from our existing order entry
system which requires that every company entry must have a
corresponding shiplocation. I know it sounds redundant,
but it was created many years ago.

I'm trying to make it easier for the user so they don't
have to retype information when entering a prospect. Once
it is entered in the Company form, I want the exact same
information to show up in the ShipLoc Form (at times,
there may only be a street address change). I'm currently
using the "default value" property for each field on on my
ShipLoc form and inserting: =[Forms]![Company]!
[CompanyName] and changing the corresponding field name
respectively.

Unfortunately, due to my inexperience at VB, when entering
a new company or prospect, the data in the ShipLoc Form is
not being inserted in the ShipLoc Table.


It seems that the default value property is determined
before you get to the subform and it's not reset in sync
with what's happening on the main form.

The thing that appears to work for me is to use the subform
Control's Enter event to execute:
Me.Recalc

BTW, it may be a little better to set the DefaultValue
property to:
Parent.CompanyName

instead of
Forms!Company!CompanyName

and, AFAICT, there is no need to use an = sign with this.
 

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