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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access one form from multiple forms 1

Status
Not open for further replies.

DLynnTX

IS-IT--Management
Dec 9, 2004
67
US
I have a form that is used for creating a new office note and it needs to be accessed from 8 different forms. I do not want to create 8 different office note forms though.

I have one form working and here is the code I'm using in the On Load event:

Private Sub Form_Load()
Me![OfficeNoteDate] = Date
Me![ClientID] = Forms![Call List for NonRA]![ClientID]
Me![UnitID] = Forms![Call List for NonRA]![Unit ID]
End Sub

I need to be able to replace "Call List for NonRA" with the other 7 form names, depending on which one the button is pressed on (i.e. Call List for NonRA, RA Call List, Exceptions List, etc).

I found posts about using various forms with one query, and a post about using If, Then, but I don't understand how to determine what form is open when you press the button.

Hope I have explained this in enough detail.

Thank you for your help.

Deniece
 
The simplest thing might be to reverse your process a little. In other words, rather than "pulling" the data from this form, "push" it from the calling form when you open this one. You could also use OpenArgs, but since you have more than one value to pass you'd have to parse the values.

Paul
MS Access MVP 2007/2008
 
Wow, looks like I'm going to have to do some more searching - thank you both for your posts, but they are way over my head. I will search for OpenArgs and parsing and see where I get from there. Thank you.
 
Ok... I'm going to just create the other seven forms. I've read all about OpenArgs, and can't figure out how to send a formname rather than a fieldname. So, it's going to be faster (though not as "clean") to just create the forms.

Thank you.
 
Don't do that:

DoCmd.OpenForm "SecondFormName", , , , , , "CallingFormName"

Private Sub Form_Load()
Me.FieldName = Forms(Me.OpenArgs).FieldName
End Sub

Paul
MS Access MVP 2007/2008
 
Oh my goodness - I can't believe how easy that was!!! It worked like a charm, and luckily I decided to go to bed soon after the "make all forms" decision and woke up at 3:30 this morning to get a fresh start. Thank you Paul, for your help. It does frustrate me that I was not able to figure it out myself. Here's the code I used in the On Load event of the "single" form in case someone else is looking for the same solution:

Private Sub Form_Load()
Me![OfficeNoteDate] = Date
Me![ClientID] = Forms(Me.OpenArgs).[ClientID]
Me![UnitID] = Forms(Me.OpenArgs).[Unit ID]
End Sub

Thank you again Paul!
 
No problem; glad we got it sorted out for you.

Paul
MS Access MVP 2007/2008
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top