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

Pass Info from form 1 to form 2

Status
Not open for further replies.

barit

Technical User
Jun 29, 2004
38
CA
I have a form called CreateMailList that consists of a multiselect list box,two fields (MailingListNameID and MailingListName) and a command button. The Command Button is being used to restrict records shown on the form. This finally works great.(Thanks to the help of others)

I now want to add a second command button that will open up a second form. Form2 needs to be populated with the selected records from form1 identified on it. I need to then be able to have then end-user add information to each of these records on form2. In addition, the user should
be able to add a record individually without having to go back to Form1. Can anyone help me in identifying how to do this?


Do I use a DoCmd.Open Form.. If so what would this code look like and what do I put on form 1 vs form2

Do I use Link Criteria..If so what would this code look like

Do I use some other method or can this not be done at all.


I really am at a loss as to how to proceed. HELP PLEASE!!I am pleased to furnish additional details if required.

 
Here's an example that runs when Command1 is clicked on Form1. It opens Form2 and populates Text2 with the data from Text1:
Code:
Private Sub Command1_Click()
    DoCmd.OpenForm "Form2"
    Forms!Form2!Text2 = Me.Text1
End Sub

See if this helps.
 
Well, as far as the whole idea, I kind of understand, but not totally. For example, if you could create a totally new record on the second form without using the first form, then why use the first at all, unless you are only using the first as a lookup form, and the second as the main form for adding/editing records.

Anyway, from what you have mentioned, I would think it could be accomplished something like the following:

First, the following info would be equal to the variables you mentioned above:
CreateMailList (your first form)
frmForm2 = would be your "second form"
and a few controls just for reference:
txtText1 txtText2 cmbCombo3
cmdOpenForm (your button for opening 2nd form)
txtForm2Text1
txtForm2Text2
txtForm2Text3

Without using all actual names from your controls, here is the general idea:
Code:
Private Sub cmdOpenForm_Click()
  Dim strText1 As String, strText2 As String, strCombo3 As String
  
  strText1 = txtText1
  strText2 = tstTest2
  strCombo3 = cmbCombo3

  DoCmd.OpenForm("frmForm2")
  DoCmd.CloseForm("CreateMailList")
  
  txtForm2Text1 = strText1
  txtForm2Text2 = strText2
  txtForm2Combo3 = strCombo3

End Sub
Of course, you may need to change a little with the format for OpenForm and CloseForm depending up what you want to do. Just start typing it, and after you put the Form Name, put a ',' and there will be a popup there which will put in bold what you need to put in next. And once you've got the code, you could just post back here with any errors if can't find the help otherwise. The help file helps some of the time, and sometimes you can get help by copying the error message and pasting to google, but if that all doesn't work, I'm sure someone here can help you get it figured out. [WINK]


Stephen [infinity]
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top