Pass a value to a subform

P

Prohock

I have a form that the user enters an ID number into a text box called
"IDnumber". If the ID number is not in the database a demographic form
"FrmDemographic" opens to a new record so that information for the new ID
number can be entered. I would like the ID number entered in "IDnumber" to be
passed to the ID field also, "IDnumber" in the subform so that it does not
have to be entered again. Have the follow so far.

If DCount("IDnumber", "TbDemographic", stLinkCriteria) = 0 Then
DoCmd.OpenForm "FrmDemographic"
DoCmd.GoToRecord , , acNewRec
 
D

Dirk Goldgar

Prohock said:
I have a form that the user enters an ID number into a text box called
"IDnumber". If the ID number is not in the database a demographic form
"FrmDemographic" opens to a new record so that information for the new ID
number can be entered. I would like the ID number entered in "IDnumber" to
be
passed to the ID field also, "IDnumber" in the subform so that it does not
have to be entered again. Have the follow so far.

If DCount("IDnumber", "TbDemographic", stLinkCriteria) = 0 Then
DoCmd.OpenForm "FrmDemographic"
DoCmd.GoToRecord , , acNewRec


What you are describing is not a subform, but rather a second main form that
is logically related to your original form. Here's one way to do what you
want:

If DCount("IDnumber", "TbDemographic", stLinkCriteria) = 0 Then
DoCmd.OpenForm "FrmDemographic", DataMode:=acFormAdd
Forms!FrmDemographic!IDnumber = Me!IDnumber
End If
 
P

Prohock

Thanks Dirk!

Dirk Goldgar said:
What you are describing is not a subform, but rather a second main form that
is logically related to your original form. Here's one way to do what you
want:

If DCount("IDnumber", "TbDemographic", stLinkCriteria) = 0 Then
DoCmd.OpenForm "FrmDemographic", DataMode:=acFormAdd
Forms!FrmDemographic!IDnumber = Me!IDnumber
End If


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 

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