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

lookup function? 2

Status
Not open for further replies.

Allilue

Technical User
Sep 14, 2000
189
GB
hello,

i have multiple forms that require the input of data. the first form has several fields to select a name, then enter other details. then i have another form that opens (first one closes) but i want to carry over the name that was selected in the first form. can i do a lookup function that picks up the name from the first form, even though it has closed?
 
Alli,

If possible. could you just make the first form invisible? If not, I think you are going to have to create and use global variables...

HTH... Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
If you are opening the second form from the first you could do something like:
DoCmd.OpenForm "NameOfForm2"
Forms![NameOfForm2]![NameOfAField]= Forms![NameOfForm1]![NameOfAField].

As Terry suggests, you could certainly hold the form open but keep it invisible if you open the second form from elsewhere. Gord
ghubbell@total.net
 
ok, well i have it half working...
with the code below, the second form opens with the name already input in the field as i want it. the only problem is that i get an error saying "type mismatch", then i see the second form, but cannot save. the first form does not close. is there something i need to alter?

Private Sub btnAddName_Click()

On Error GoTo Err_btnAddName_Click
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm "frm2"
Forms![frm2]![RetailerName] = Forms![frm1]![SelectName]
DoCmd.Close "frm1"

Exit_btnAddName_Click:
Exit Sub

Err_btnAddName_Click:
MsgBox Err.Description
Resume Exit_btnAddName_Click

End Sub
 
Evil little things....
Change that last line to:

DoCmd.Close

It'll work! Gord
ghubbell@total.net
 
i tried that originally, but that just leaves the first form open. i think it's reading from the previous line to close the second form? it looks like the second form opens, then immediately closes. can i close the form prior to the line - Forms![frm2]![RetailerName] = Forms![frm1]![SelectName]?
 
More evil little things...

DoCmd.Close acForm, "Frm1"

Will work or I'll go home! Gord
ghubbell@total.net
 
Hi,

Because it works you can leave it alone, but next time you might like to think about passing arguments to the second form ie

Private Sub btnAddName_Click()
DoCmd.OpenForm "Form2", , , , , , me.[SelectName]
DoCmd.Close acForm,"Form1"

Form2 would have to be set up to take the arguments in the OpenForm event.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top