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

Working with a copy of a form

Status
Not open for further replies.

h3lm3t

Technical User
May 27, 2003
16
0
0
GB
Hi there thanx for looking, i need help understanding and using a copy of a form.

I want the user to view some records via a form, but when the want to edit a specific record, i want a popup of the currently selected record to appear as a new form.

Originally i made 2 forms, with an edit button on the source, that when clicked opened the destination from and populated the destination form data from the matching source record. The destination allowed editing, the source did not.

But as i am using many forms now, the number of forms is growing very rapidly.

Then i noticed the form copy:

Dim destination as new Form
set destination = Form_frmSource

Could you explain this a little, i think its an exact copy of the source form, and that i can now change the destination form however i want, and changes will not reflect back to the source. If thats the case how do i add controls etc. to the destination ??

I'm a bit confused, can you help.

Thanx in advance for all help.
regards

h3lm3t


 
The code just sets a reference to the form frmSource. This will typically be followed with references to controls on its, its properties or data on it.
It is not a copy of the form in the true sense of the word, in that changes made with it won't be saved (unless code tells it to save).

To modify the form via code, each form has a collection of controls on it, if in your code you put

dim ctl as Control
for each ctl in destination.Controls
debug.Print ctl.Name & " " & ctl.ControlType
Next

you could list the name and types of controls. The types are numeric, but there are constants representing them which makes the code easier to read - things like acTextBox, acCheckBox, acOptionGroup etc.
To add a new control, set the options in the ctl variable, including type, location, labels etc. then append it to the controls collection.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top