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

Open form, fill it, go back to original

Status
Not open for further replies.

Joallyn

Technical User
Jul 26, 2002
44
US
hi listers,

I've scanned through the archives and couldn't find the answer to these problems. I think they're easy ones, but I don't know how to do them. My already low Access self-esteem is sinking even lower...aaackk.

I have a combo box on a form ("Form Parent") that allows the user to input data ("Name"). If the entered name doesn't already exist, the user is prompted to see if he/she wants to record it (i.e., "This name is not in the list. Do you want to add it?"). Then another form pops open ("Form Child") to handle the data input.

My questions are:

1.) When the Child form opens, it prompts the user to enter the new name again. Since the user already typed in that name once, in the Parent form, I'd like to minimize the typing and transfer the name automatically into the Child form. I'm sure that's possible; could someone fill me in on how that's done?

2.) Once that name is entered, I'd like to give the user 2 options through command buttons: 1., enter another name, just in case they suddenly thought of someone else; 2. go back to the form/record they were using before, and focus on the next data field. I'd like something a little more elegant than just clicking on the Close button in the corner...I just can't figure out how to do THAT, either.

I'd appreciate suggestions, comments, and the like!

thanks, and happy Friday....

J
 
1. If the parent form is still open, you should be able to access the field directly using syntax like:

=Forms!FormParent!fieldx

where fieldx is the name of your control in which the user types the name


2. Again, if the parent form is still open, you can just close the child form with

DoCmd.Close

and the underlying parent form will still be displayed.

Hope this helps...

J. Jones
jjones@cybrtyme.com
 
Or you can save the name as savName = me.name just before openiing the child form and put the me.name in the child form right after it is opened. The first me is the name in the parent form and the second me is in the child form.

rollie@bwsys.net

P.S. Do this on the form open event
 
hi and thanks for replying.

I got the command button to work using DoCmd.Close, but I've unsuccessfully tried both of the suggestions for the other problem.

The results:

1. When I use #1 (=Forms!ForParent!fieldx), the form still opens up with a blank. Since I use the following code to prompt and then open the entry form, I tried taking out the line "DoCmd.RunCommand acCmdUndo", but unfortunately that didn't help:

intAnswer = MsgBox("This name is not in the list. Do you want to add it?", vbYesNo, vbQuestion)

If intAnswer = vbYes Then
DoCmd.RunCommand acCmdUndo
DoCmd.OpenForm "frmPersonnel", acNormal, , , acFormEdit, acDialog
Response = acDataErrContinue
Else
Reponse = acDataErrContinue
End If


2. I tried using Rolliee's suggestion but I'm tripping over my lack of VB experience; I'm not sure what I should take verbatim and what I should use as placeholders (does "me" in me.name remain "me", or does it transmogrify into something else?).
thanks for the suggestions, and sorry about the cluelessness on this end...

J
 
Well, this isn't going to help, but maybe it'll save you some time. I've tried both of these solutins and they don't seem to work.

I took your code for #1 and created a sub form that came from a NotinList event. Upon first run, the parent form reloaded and the name field was set to "". I took out the acCmdUndo line and then ran it again. The field wasn't set to "" and showed my text, but it still wasn't transfered to the new form.

The new form popped over the parent form (parent not closed) and in the OnOpen AND in the OnLoad, I had the text box equal to the parent form field (me!text0 = Forms!Clients!text1), but the new form text field still showed blank even though the text appeared in the parent form field.

I then attempted to save the data in another variable (me!savName - the me! reflects the active/focused form name and can be as is or replaced with Forms!(FormName)!savName). A debug error occurred saying invalid use of NULL for savName, meaning the data in the parent form field was not even seen.

So, while I haven't been able to fix the problem you've stated, the solutions presented don't seem to work currently.

As for #2, you can add 2 buttons to the new form, 1 that closes and returns to the parent form and 1 that goes to a new record (docmd.GoToRecord,,acNewRec). With the text box on the new form having a control source of the data field used to create the combo box, anything typed into it will be added to the combo box list. When closing the new form, requery the combo box on the new form and the newly typed data should appear. This option should work even if you can't get #1 to work.

DreamerZ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top