code to save and close one form and open another

tonylpcs

Registered User.
Local time
Today, 05:26
Joined
Feb 15, 2011
Messages
27
Hi everyone,

I got a button that will be called "nextpage"
in the first form called "names"

i want to be able to click on it and get it to close and save the form im in and open a new form called "moredetails" but open it on the record i was on in the first form?

how can i do this?

thanks in advance

Tony
 
Exatly as written:
Code:
Docmd.close acForm, Me.Name, acsaveno
Docmd.openform "moredetails"
 
You could use a tab control and separate data elements on specific tabs...
 
Hi It works but doesn't open the new form on the record i was previously on!

any way this can be done?

thanks

Tony
 
If you want to minimize # of recs you have available for a form (best practice to do), then another option is to pass the key that identifies the record to the new form and in the open event of that second form, re-create or modify the query that generates the data for the form and requery so you bring up only one record.
 
If you want to minimize # of recs you have available for a form (best practice to do), then another option is to pass the key that identifies the record to the new form and in the open event of that second form, re-create or modify the query that generates the data for the form and requery so you bring up only one record.
Docmd.OpenForm "FormName",,, "ID = " & Me.IDControl

Is the best way. Building the sql in code is not necessary in a simple case such as this. If this was a search form then yes what you advised would be best practice.
 
If the query for the second form has thousands of records, then each of those records would have to be transferred over the network, even though you would be accessing only one of them, hence best practice to create queries that get only the records you need.
 
I don't will transfer all the records over the network before filtering. It will filter then get the records over.
 
I believe the only way to do that is via my original recommendation. Creating a filter on a recordset that has already been constructed just displays the record(s) you want to see.
 

Users who are viewing this thread

Back
Top Bottom