Copy control values from form to form

D

Duck

I have a simple form which is used to generate a list of appointments
in the form of a weekly report. I have several days in which the
appointments are the same (ie work). The form has about 10 input
controls (ie Place, Address, City, State, Phone, Contact Person, etc).

I am looking for a way to only have to input these bits of data once
on the opening form and then go to the next form with all the
information from the previous form and only havfe to change the date,
while having each form generate a seperate record in the underlying
table from which the report is generated.

Can anyone help me??
 
B

boblarson

From the one form to the other:

With Forms!Your2ndFormNameHere
.Address = Me!Address
.City = Me!Address
.State = Me!Address
End With

Just add the fields you need like that (Me is a keyword that is a shortcut
that refers to the current class that the code is on. In this case it is the
form you are copying from.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com

__________________________________
 
D

Duck

From the one form to the other:

With Forms!Your2ndFormNameHere
    .Address = Me!Address
    .City = Me!Address
    .State = Me!Address
End With

Just add the fields you need like that (Me is a keyword that is a shortcut
that refers to the current class that the code is on.  In this case it is the
form you are copying from.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials athttp://www.btabdevelopment.com

__________________________________







- Show quoted text -

I am entering a new record with the SAME form, but I want the contents
of the previous record to carry over on the new iteration of the
form. I don't think this solution will work under these
circumstances..will it?
 
B

boblarson

Then here's ONE way of many to do it:

In the General Declarations Section of the Form Module, create variables for
the objects you want to copy.

Dim strAddress As String
Dim strCity As String
Dim strState As String

Then in the Before Update event of the form:


strAddress = Me!Address
strCity = Me!Address
strState = Me!Address
etc.

Then, in the Form's CURRENT event use:
If Me.NewRecord Then
Me!Address = strAddress
Me!City = strCity
Me!State = strState
etc.....
End If

That SHOULD get you what you want.


--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com

__________________________________
 
B

boblarson

Although, if you are storing the SAME data over and over then you really
might want to look at the design as it may not be normalized.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com

__________________________________
 
D

Duck

Then here's ONE way of many to do it:

In the General Declarations Section of the Form Module, create variables for
the objects you want to copy.

Dim strAddress As String
Dim strCity As String
Dim strState As String

Then in the Before Update event of the form:

strAddress = Me!Address
strCity = Me!Address
strState = Me!Address
etc.

Then, in the Form's CURRENT event use:
If Me.NewRecord Then
   Me!Address = strAddress
   Me!City = strCity
   Me!State = strState
etc.....
End If

That SHOULD get you what you want.

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials athttp://www.btabdevelopment.com

__________________________________






- Show quoted text -

THANKS A MILLION....That solution got me on the right track...Instead
of placing the code for the new record in the current event, I tied it
to the click event of a button on the form so I would have the option
of using the same data or not.....again thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top