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!

Taking FORM details to next form

Status
Not open for further replies.

anthonyevans

Technical User
Mar 12, 2001
2
0
0
GB
Dear All,

I am somewhat new to Access 2000.

Basically I have one form with various details that a user enters. At the end of that form there is a button that takes you to another form. I would like the details of for example, name and date of birth that have been entered to be taken to the new form auomatically. Do I do this with a sub-form ? and if so how ? or is there another way ?

Best Regards,

Anthony
 
The most common way to pass data from one form to another is the OpenArgs argument of the OpenForm method. In your case, with several values to pass, you'd have to combine them into a single string with some kind of separator between them, pass that string as the OpenArgs argument, and then retrieve the string and break it apart in the target form's Open event.

Another way, which might be easier in this case, is for the invoking form to save the data in global variables. These are variables declared in the Declarations section of a standard module. The target form's Open event would then retrieve the values from the variables and load them into its controls.

Note: With either of these approaches, I'm assuming that the target form is either not bound to a record source, or is only used for data entry (the Data Entry property is set to Yes). If the target form is bound and displays records for editing, moving in data from the invoking form would update the first record displayed, which is probably not something you want to do.

Also, if the target form can be opened independently, or opened by other invoking forms, you'll have to figure out a way to indicate that data is being passed, and implement it in the target's Open event. Rick Sprague
 
I've done this in a case where employees are participating in a contest. The initial form is a master scorecard and is based on the Employee Table with their EmpID as the key.

When they earn points for a particular achievement, the appropriate command is selected (eg: Record New Sale) to open the second form.

As Rick said, the On Open event for the New Sales Form is set to populate some of the indentifier and date fields in the form based on the Employee table.

The first event On Open has to be Go To New Record or you would be overwriting an existing record.
 
Boxhead's comment on GoToNewRecord is one thing I forgot to mention. You can do that instead of setting the Data Entry property to Yes.

I might also mention a warning: If your target form is already open when the invoking form tries to open it, it will be brought to the front but its Open event procedure won't be called. In that case, your data won't get loaded into it, it will just continue to display whatever record it was on at the time. You need to account for this in planning how the user interacts with your application. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top