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

Open new form with new record for option picked from other form

Status
Not open for further replies.

3699wat

Technical User
Sep 30, 2002
28
US
I kinda posted this earlier but I’m still stuck.
Form A has listbox and button. I chose a name on the listbox and click on the command button to open a new form (filter is NameID). Like to open this new form with a new record for that name and with the name already displayed. This form is bound to table tblNotes and contains a subform bound to tblServices (link is ServiceID).
I tried this with the help of a previous post. The form opens with the name displayed but also with data from the record .
Any suggestions??
 
I'M NOT SURE THAT I CAN HELP YOU BUT I WILL TRY. FIRST, LET ME MAKE SURE I UNDERSTAND YOUR PROBLEM. FORM A POPS UP AND THE USER PICKS FROM A LIST BOX A NAMEID, THEN CLICKS ON COMMAND BUTTON, TO OPEN A NEW FORM, SAY FORM B. ON FORM B ALL YOU WANT TO SEE IS THE NAMEID SELECTED FROM THE LIST BOX ON FORM A. RIGHT SO FAR? BUT WHEN YOU CLICK ON THE COMMAND BUTTON FORM B OPENS NOT AS A NEW RECORD, BUT AS AN EXISTING RECORD? ASSUMING THIS IS CORRECT, I HAVE A QUESTION. IS FORM A POPUP OR FULL SCREEN? ARE YOU CLOSING FORM A BEFORE OR AFTER YOU GO TO FORM B? IS FORM B FULL SCREEN OR POPUP? I AM ASKING THE FORM SIZE QUESTION BECAUSE THERE ARE A COUPLE OF WAYS TO HANDLE THIS PROBLEM AND THE MOST GRACEFUL SOLUTION WILL DEPEND UPON THE FLOW YOU WISH THE PROGRAM TO HAVE.

 
You did understand the problem allright. Here's are the specifics you asked for. Both forms are full screen. Form B is opened by using a command button on form A after selecting a person in the listbox. As already explained it is supposed to open with a new record for the person choosen and the name should be displayed on the form. Form A actually does not close when form B opens but is set to invisible.
Thanks for your efforts.
Marcel
 
Have you tried on your button
Click()
Docmd.openform"formB"
docmd.gotorecord,,acnewrec
forms!formB!nameid = forms!formA!listboxname

Mike
 
I apologize for the delay in my answer. My job really screws up my free time. Ok we want to accomplish 2 things, first we want Form B to open for data entry and then we want to set a value for NameID. First on the command button OPEN at the event for the ClickEvent use DoCmd.OpenForm. In the arguments for OpenForm, check out DataMode. Read about this in Help>AnswerWizard>Open Form. I've used this and my code reads:
DoCmd.OpenForm "frmVendor", acNormal, , , acFormAdd, acDialog
This should make FormB open to receive new records instead of opening to display current data. Second, we should set a value for NameId. That can be accomplished by setting the default value for the control NameId to equal FormA list box value.
There is more than one way to skin a cat. MgmSlate is correct in their response in that you are accomplishing both task from the command button OPEN. If you get really stuck, make one thing happen correctly and then do the second. I do not always write the most graceful code, but the important thing is that is works. Let us know how you come out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top