How do you carry data from one form to another? control referencin

G

Guest

Please help if you can:

I have a combo box on a form (frmTest) that contains zipcodes. In the
'notinlist' function, I have working code that asks, "Do you want to add
'11122' to the zipcode table?" Yes/No. If you choose yes, then the data
entry form (frmZipcode) opens to add a zipcode, city, and state. Closing
this form saves the new zip, etc.; closes the zip data entry, and advances to
the next new record on frmTest.

The problem: If a person enters a zipcode (22211) on frmTest, and they
choose to enter it into frmZipcode, I do NOT want them to have to retype the
zipcode on frmZipcode...I want it to 'carry over' from the first form where
they first entered it. I know that I'm missing something easy
here...something wrong with referencing the field or something. I would
greatly appreciate any help.

Here's the code on the not in list:
Public Sub Zip_NotInList(NewData As String, Response As Integer)

If MsgBox("Do you want to add '" & NewData & "' to the zipcode table?",
vbOKCancel, "Add New Item?") = vbOK Then

'Remove new data from combo box so control requeries
DoCmd.RunCommand acCmdUndo

'Display Zipcode form to collect new data.
DoCmd.OpenForm "frmtblZipcode", acNormal, , , acFormAdd, acDialog,
NewData


'Continue without displaying default error message.
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If


End Sub


============
I was trying something like:
Forms![frmtblZipcode]![Zipcode] = NewData

HELP!!!!!!!!!!!!!!

Have a great day,
Marjorie
 
N

Nikos Yannacopoulos

marjorie,

I'm not sure why this wouldn't work, but since you bother to pass along
NewData in the opening arguments, you might as well use this in the On
Open event of frmtblZipcode:

Me.Zipcode = OpenArgs

HTH,
Nikos
 
G

Guest

I'm not sure if this will help, but I am using it successfully on a parent
form to pass to a subform. In the cmd btn Yes, where I presume you open
frmZipCode, also place a line somethin like this ...

Form_frmZipCode.textBoxname.Value = Form_frmTest.textboxname.Value

HTH,
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top