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

Open form2 with button and populate field in with field in form1

Status
Not open for further replies.

williekay

Technical User
Jun 30, 2003
121
0
0
US
This may sound a liitle more simple than it is. I have a form that users fill out to start projects, the primary key is an autonumber field (CHARTER NUMBER). At the bottom of the form are command buttons to different blank forms. I want a user to be able to hit the button and have the CHARTER NUMBER populate the CHARTER NUMBER field on form2. This is where I get sidetracked, the user may have to fill out more than one (sometimes up to ten) of these form2 documents. I want as many as they need to have the CHARTER NUMBER filled in by the press of the button on form1. I've got a field called 5S# which is an autonumber and arranged as the primarykey on form2. The code I'm using doesn't work.

williekay
 
Hi

Have you tried exporting all the already input data on the various controls on Form1 to public variables when clicking any of your command buttons and then re-importing the data back to the relevant fields on any forms your command buttons open? You'll need to create the public variables in a module and pass the already input criteria to them when clicking your command button that opens your new form, then use the On Open event of the newly opened form to re-assign the data to the correct fields.

Hope that helps

Alan
 
Hi,

One simple way of doing is to just write this. Assuming that u want to open form in new record mode

.----------------------------------------------
DoCmd.OpenForm "Form2", acNormal, , , acFormAdd
Forms!form2!CharterNum = Me.CharterNum

'Close form 1
DoCmd.Close acForm, "Form1", acSaveYes
'----------------------------------------------

If you want to link Charter Num of both forms than follow this approach.

1.Open form2 with Link criteria like

DoCmd.OpenForm "Form2", , , "[CharterNum]=" & Me.CharterNum
DoCmd.GoToRecord acActiveDataObject, , acNewRec

2. Set the default value property of CharterNum or form2 as Forms!Form1!CharterNum

Hope it helps



Cheers!
ÙÇãá
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top