Pass a value to a subform

  • Thread starter Thread starter Prohock
  • Start date Start date
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
 
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
 
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)
 
Back
Top