Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing text value from Form1 to bound text in Form2? 1

Status
Not open for further replies.

Apollo6

Technical User
Jan 27, 2000
418
US
I have frmMain with txtPatientNumber. When I click a button, a new form opens to enter drug history. It contains a bound field, txtPatientNumber, as well as other bound fields that the user would enter data. I want it to automatically populate with the current patient number from frmMain to be entered into the drug history table. Basically, the user doesn't need to enter the patient number, I'll just grab it from frmMain, which is still open.

I know I have done this before, for the life of me, I can't get it to work now. Just need a refresher on how to go about this. I keep getting an error stating it can't assign a value to the txtPatientNumber bound text box I have on the second form.

Any help is appreciated.
 
How are ya Apollo6 . . .

Note: if [blue]txtPatientNumber[/blue] is a [purple]primarykey[/purple], this wont work (duplicate PK!).

In the Load event of the Other Form:
Code:
[blue]   If Not Me.NewRecord Then DoCmd.RunCommand acCmdRecordsGoToNew
   Me!txtPatientNumber.DefaultValue = Forms!frmMain!txtPatientNumber[/blue]
Form frmMain just open the Other Form with DoCmd.OpenForm . . .

Calvin.gif
See Ya! . . . . . .
 
Better now. I got that to work with your suggestion. Must have been having a brain cramp.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top