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!

REFERING TO TWO FIELDS IN 2 DIFFERENT FORMS 2

Status
Not open for further replies.

franks

Programmer
Aug 16, 2001
9
ES
Hi
I am trying to copy field from one form and "paste" it to another form field.
Basically A NONINLIST routine on PreviousForm opens the CitiesForm, creates a new record, and the field from the original form (LoadingCity) gets copied to a field on the newly opened form (CityName).
I´ve done this but it doesn´t work.

stDocName = "CitiesForm"
DoCmd.OpenForm stDocName
DoCmd.GoToRecord , , acNewRec
Forms![CitiesForm]![CityName] = Forms![PreviousForm]![LoadingCity]

I know it is super easy and I have done a search in the forum without success.
Can anyone help ?
Regards
 
Hi!

Try this:

In the NotInList Event

stDocName = "CitiesForm"
DoCmd.OpenForm stDocName, , , , acFormAdd, , Me![LoadingCity]

In the Form_Load event of CitiesForm

If Nz(Len(Me.OpenArgs),0) <> 0 Then
Me.CityName = Me.OpenArgs
End If

hth
Jeff Bridgham
bridgham@purdue.edu
 
If your LoadingCity is Not In List of a combo box, try Forms![PreviousForm]![LoadingCity].text
 
Hi both and thanks for replying so quickly.
Dear Jebry, yor code looks great, however because the value on the LoadingCity is NULL, when it opens the CitiesForm, it puts nothing on the CityName.
I have used the code with a variable (DoCmd.OpenForm stDocName, , , , acFormAdd, , &quot;New City&quot;) and it DOES puts it on the form. So it works, however what I´ve typed on the COMBOBOX doesn´t transfer across.

I believe temclerk is telling me about it on his message (the new city is not on the listbox...) but the code he/she gives me I am not sure where to put it...
Any further help is appreciated, however I understand if you have better things to do...

regards
 
Hi!

My mistake! Use:

DoCmd.OpenForm stDocName, , , , acFormAdd, , Me![LoadingCity].Text

And use the rest of the code as is. Thanks TempClerk!

hth
Jeff Bridgham
bridgham@purdue.edu
 
what can I say ?
Thank you both so much, it works great !!!!

And you are the champions, my friends...(imagine that with Queens´ music on the background..)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top