default value from main form ID

  • Thread starter Thread starter deb
  • Start date Start date
D

deb

I need to ast the default to my forms combobox to the fields [LastName]
by using a field in the main form. The problem is... the field in the main
form has the PMID and I need the [lastname] associated with the PMID

something like this??
= [tPM]![LastName] where [tPM]![PMID] = [Forms]![fProject]![PMID]
 
Hi Deb,

if the Last Name is associated with PMID, why would you not be referring
to the ID and simply displaying the Last Name?

you can set the Default Value property of a form control to a control on
another form (but it must be open! or you will get an error)

[Forms]![fProject]![PMID]

you can use a combobox to store the ID and show the name

~~~

if you simply want to display the last name from the first form, and you
know that the fProject form will be open, you can do this in the
ControlSource of a textbox:

= IIF( IsNull([Forms]![fProject]![PMID]), Null,
[Forms]![fProject]![PMID].column(1))

column indexes start at zero, so column index 1 is really column 2

I used IIF to test to ensure that the control is filled out -- if not,
you will get an error if you don't test for it

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*
 
Your suggestions, below, will display the ID number, I need to show the name
associated with this ID number. How can I take the ID number from the
combobox on the main form and use it as the default name in the combo box in
the sub form?

[Forms]![fProject]![PMID]

= IIF( IsNull([Forms]![fProject]![PMID]), Null,
[Forms]![fProject]![PMID].column(1))

--
deb


strive4peace said:
Hi Deb,

if the Last Name is associated with PMID, why would you not be referring
to the ID and simply displaying the Last Name?

you can set the Default Value property of a form control to a control on
another form (but it must be open! or you will get an error)

[Forms]![fProject]![PMID]

you can use a combobox to store the ID and show the name

~~~

if you simply want to display the last name from the first form, and you
know that the fProject form will be open, you can do this in the
ControlSource of a textbox:

= IIF( IsNull([Forms]![fProject]![PMID]), Null,
[Forms]![fProject]![PMID].column(1))

column indexes start at zero, so column index 1 is really column 2

I used IIF to test to ensure that the control is filled out -- if not,
you will get an error if you don't test for it

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*



I need to ast the default to my forms combobox to the fields [LastName]
by using a field in the main form. The problem is... the field in the main
form has the PMID and I need the [lastname] associated with the PMID

something like this??
= [tPM]![LastName] where [tPM]![PMID] = [Forms]![fProject]![PMID]
 
My mistake,

= IIF( IsNull([Forms]![fProject]![PMID]), Null,
[Forms]![fProject]![PMID].column(1))

Works perfectly!!! Thank you!!!
I thought I tried this before but evidently I did something wrong because
your code works great.

--
deb


strive4peace said:
Hi Deb,

if the Last Name is associated with PMID, why would you not be referring
to the ID and simply displaying the Last Name?

you can set the Default Value property of a form control to a control on
another form (but it must be open! or you will get an error)

[Forms]![fProject]![PMID]

you can use a combobox to store the ID and show the name

~~~

if you simply want to display the last name from the first form, and you
know that the fProject form will be open, you can do this in the
ControlSource of a textbox:

= IIF( IsNull([Forms]![fProject]![PMID]), Null,
[Forms]![fProject]![PMID].column(1))

column indexes start at zero, so column index 1 is really column 2

I used IIF to test to ensure that the control is filled out -- if not,
you will get an error if you don't test for it

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*



I need to ast the default to my forms combobox to the fields [LastName]
by using a field in the main form. The problem is... the field in the main
form has the PMID and I need the [lastname] associated with the PMID

something like this??
= [tPM]![LastName] where [tPM]![PMID] = [Forms]![fProject]![PMID]
 
deb said:
I need to ast the default to my forms combobox to the fields [LastName]
by using a field in the main form. The problem is... the field in the main
form has the PMID and I need the [lastname] associated with the PMID

something like this??
= [tPM]![LastName] where [tPM]![PMID] = [Forms]![fProject]![PMID]
 
Back
Top