Default Value Problem

J

JS

I have a form with a subform. On the subform, it opens to another subform
with a field lngMDContractID. I am trying to carry the Id to the second
subform. In the field properties: Default Value =
Forms![subfrmMedicalInfo]![lngMDContractID]. I have used this type of
expressions previously and it works. It display Name? which is telling me it
doesn't recognize the naem. I checked the name of the subform and the field
name and I made no mistake. Is there something I should know about using
default values from a subform to another subform?

I tried the AfterUpdate but it gave me a blank value instead.

Any help is appreciated!
 
D

Douglas J. Steele

Forms being used as subforms do not get added to the Forms collection.
Instead, you need to address them through their parent form.

In general, to refer to a control on a subform, you'd use:

Forms!NameOfParentForm!NameOfSubformControlOnParentForm.Form!NameOfControlOnSubform

Note that depending on how you added the form to be used as a subform to the
parent form, the name of the subform control may not be the same as the name
of the form being used as a subform. It's important that you use the name of
the subform control on the parent form.
 
J

JS

Thank you. I will give it a try and let you know how this worked. Thanks.

Douglas J. Steele said:
Forms being used as subforms do not get added to the Forms collection.
Instead, you need to address them through their parent form.

In general, to refer to a control on a subform, you'd use:

Forms!NameOfParentForm!NameOfSubformControlOnParentForm.Form!NameOfControlOnSubform

Note that depending on how you added the form to be used as a subform to the
parent form, the name of the subform control may not be the same as the name
of the form being used as a subform. It's important that you use the name of
the subform control on the parent form.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JS said:
I have a form with a subform. On the subform, it opens to another subform
with a field lngMDContractID. I am trying to carry the Id to the second
subform. In the field properties: Default Value =
Forms![subfrmMedicalInfo]![lngMDContractID]. I have used this type of
expressions previously and it works. It display Name? which is telling me
it
doesn't recognize the naem. I checked the name of the subform and the
field
name and I made no mistake. Is there something I should know about using
default values from a subform to another subform?

I tried the AfterUpdate but it gave me a blank value instead.

Any help is appreciated!
 
J

JS

This did not work for me because the field I want as a default is not on the
Parent form. I have an Item ID on the parent form. This field is linked to
the subform - Medical Info. Both of these forms are linked by the Item ID.

On the Medical Info subform I have a unique identifier MDContract ID that I
use to open several other subforms such as Coding, Billing by Medical ID
numbers. This field is not on the Parent form. It is the MDContractID I
want to default when you open Coding, Billing. The way it is now when you
lauch Coding, you have to key in the ID #.

Can it still be done? Doesn't sound like it unless I add the MDContractID
to the parent form. Correct? I

JS said:
Thank you. I will give it a try and let you know how this worked. Thanks.

Douglas J. Steele said:
Forms being used as subforms do not get added to the Forms collection.
Instead, you need to address them through their parent form.

In general, to refer to a control on a subform, you'd use:

Forms!NameOfParentForm!NameOfSubformControlOnParentForm.Form!NameOfControlOnSubform

Note that depending on how you added the form to be used as a subform to the
parent form, the name of the subform control may not be the same as the name
of the form being used as a subform. It's important that you use the name of
the subform control on the parent form.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JS said:
I have a form with a subform. On the subform, it opens to another subform
with a field lngMDContractID. I am trying to carry the Id to the second
subform. In the field properties: Default Value =
Forms![subfrmMedicalInfo]![lngMDContractID]. I have used this type of
expressions previously and it works. It display Name? which is telling me
it
doesn't recognize the naem. I checked the name of the subform and the
field
name and I made no mistake. Is there something I should know about using
default values from a subform to another subform?

I tried the AfterUpdate but it gave me a blank value instead.

Any help is appreciated!
 
D

Douglas J. Steele

Show the exact code you're trying to use that's failing, and explain what
the names of the controls and forms are.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


JS said:
This did not work for me because the field I want as a default is not on
the
Parent form. I have an Item ID on the parent form. This field is linked
to
the subform - Medical Info. Both of these forms are linked by the Item
ID.

On the Medical Info subform I have a unique identifier MDContract ID that
I
use to open several other subforms such as Coding, Billing by Medical ID
numbers. This field is not on the Parent form. It is the MDContractID I
want to default when you open Coding, Billing. The way it is now when you
lauch Coding, you have to key in the ID #.

Can it still be done? Doesn't sound like it unless I add the MDContractID
to the parent form. Correct? I

JS said:
Thank you. I will give it a try and let you know how this worked.
Thanks.

Douglas J. Steele said:
Forms being used as subforms do not get added to the Forms collection.
Instead, you need to address them through their parent form.

In general, to refer to a control on a subform, you'd use:

Forms!NameOfParentForm!NameOfSubformControlOnParentForm.Form!NameOfControlOnSubform

Note that depending on how you added the form to be used as a subform
to the
parent form, the name of the subform control may not be the same as the
name
of the form being used as a subform. It's important that you use the
name of
the subform control on the parent form.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I have a form with a subform. On the subform, it opens to another
subform
with a field lngMDContractID. I am trying to carry the Id to the
second
subform. In the field properties: Default Value =
Forms![subfrmMedicalInfo]![lngMDContractID]. I have used this type
of
expressions previously and it works. It display Name? which is
telling me
it
doesn't recognize the naem. I checked the name of the subform and
the
field
name and I made no mistake. Is there something I should know about
using
default values from a subform to another subform?

I tried the AfterUpdate but it gave me a blank value instead.

Any help is appreciated!
 
J

JS

Douglas, I was able to do.
I was keying the code in wrong and in the wrong area. I opened the form in
the main form to the subform. In the properties Default text box I created
the expression using the expression builder. I just clicked on all the forms
loaded expand button until I go to the subform and double-clicked on the
field I needed. It worked which was the same as the expression you gave me.

Thanks for your help. JS

Douglas J. Steele said:
Show the exact code you're trying to use that's failing, and explain what
the names of the controls and forms are.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


JS said:
This did not work for me because the field I want as a default is not on
the
Parent form. I have an Item ID on the parent form. This field is linked
to
the subform - Medical Info. Both of these forms are linked by the Item
ID.

On the Medical Info subform I have a unique identifier MDContract ID that
I
use to open several other subforms such as Coding, Billing by Medical ID
numbers. This field is not on the Parent form. It is the MDContractID I
want to default when you open Coding, Billing. The way it is now when you
lauch Coding, you have to key in the ID #.

Can it still be done? Doesn't sound like it unless I add the MDContractID
to the parent form. Correct? I

JS said:
Thank you. I will give it a try and let you know how this worked.
Thanks.

:

Forms being used as subforms do not get added to the Forms collection.
Instead, you need to address them through their parent form.

In general, to refer to a control on a subform, you'd use:

Forms!NameOfParentForm!NameOfSubformControlOnParentForm.Form!NameOfControlOnSubform

Note that depending on how you added the form to be used as a subform
to the
parent form, the name of the subform control may not be the same as the
name
of the form being used as a subform. It's important that you use the
name of
the subform control on the parent form.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I have a form with a subform. On the subform, it opens to another
subform
with a field lngMDContractID. I am trying to carry the Id to the
second
subform. In the field properties: Default Value =
Forms![subfrmMedicalInfo]![lngMDContractID]. I have used this type
of
expressions previously and it works. It display Name? which is
telling me
it
doesn't recognize the naem. I checked the name of the subform and
the
field
name and I made no mistake. Is there something I should know about
using
default values from a subform to another subform?

I tried the AfterUpdate but it gave me a blank value instead.

Any help is appreciated!
 
Top