move some values from one form to another form

S

sylvieB25

I need help with my forms in Access 2003. Basically my question is how to
move some values from one form to another. I am totally stuck and don't know
how to do it. Any help would be greatly appreciated.
Here is my scenario.
I have two forms, the main form called frmMTR and second form called
frmWarranty. I created a command button on the main form that when clicked it
will open the second form frmWarranty and copy some values form the main
form.
Here is the code I wrote; it does not work; it does not move the values.

Private Sub Export_Click()
'Opens frmWarrantyReport to populate some fields from frmMTR
'Dim stDocName As String
'Dim stLinkCriteria As String
'stDocName = "frmWarrantyReport"
'stLinkCriteria = "[DateReported]=" & "" & Me![DateReported] & ""
'stLinkCriteria = "[IssuedBy]=" & "" & Me![IssuedBy] & ""
'stLinkCriteria = "[MTRTitle]=" & "" & Me![MTRTitle] & ""
'DoCmd.OpenForm stDocName, , , stLinkCriteria
 
M

Maurice

Sylvie,

Your code will try to filter the form based on your criteria. If i
understand correctly you want to push the data from some fields to the second
form.

Try this:
Private Sub Export_Click()

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmWarrantyReport"
DoCmd.OpenForm stDocName, , , stLinkCriteria
forms!frmWarrantyReport!DateReported=me!DateReported
forms!frmWarrantyReport!IssuedBy=me!IssuedBy
forms!frmWarrantyReport!MTRTitle=me!MTRTitle

docmd.close ("form1") '-> optional close the first form if you want...
end sub

This assumes that the fields on the second form have the same fieldnames as
the fieldnames on the first form.

hth
 
S

sylvieB25

Thank so much for correcting my codes. It works, however when I have a little
problem. the first time I click the command button the values get moved for
the correct record but when i go back to the main form and select a different
record, click the command button, it shows the information of the previous
record and not the one i selected on the main form. Additional to that, each
time it moves the data on the second form, it creates 2 records. I am not
sure what this is happening.
Thank you for any suggestion you might have to correct those two issues.

SylvieB



Maurice said:
Sylvie,

Your code will try to filter the form based on your criteria. If i
understand correctly you want to push the data from some fields to the second
form.

Try this:
Private Sub Export_Click()

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmWarrantyReport"
DoCmd.OpenForm stDocName, , , stLinkCriteria
forms!frmWarrantyReport!DateReported=me!DateReported
forms!frmWarrantyReport!IssuedBy=me!IssuedBy
forms!frmWarrantyReport!MTRTitle=me!MTRTitle

docmd.close ("form1") '-> optional close the first form if you want...
end sub

This assumes that the fields on the second form have the same fieldnames as
the fieldnames on the first form.

hth
--
Maurice Ausum


sylvieB25 said:
I need help with my forms in Access 2003. Basically my question is how to
move some values from one form to another. I am totally stuck and don't know
how to do it. Any help would be greatly appreciated.
Here is my scenario.
I have two forms, the main form called frmMTR and second form called
frmWarranty. I created a command button on the main form that when clicked it
will open the second form frmWarranty and copy some values form the main
form.
Here is the code I wrote; it does not work; it does not move the values.

Private Sub Export_Click()
'Opens frmWarrantyReport to populate some fields from frmMTR
'Dim stDocName As String
'Dim stLinkCriteria As String
'stDocName = "frmWarrantyReport"
'stLinkCriteria = "[DateReported]=" & "" & Me![DateReported] & ""
'stLinkCriteria = "[IssuedBy]=" & "" & Me![IssuedBy] & ""
'stLinkCriteria = "[MTRTitle]=" & "" & Me![MTRTitle] & ""
'DoCmd.OpenForm stDocName, , , stLinkCriteria
 
P

PUrvik

sylvieB25 said:
I need help with my forms in Access 2003. Basically my question is how to
move some values from one form to another. I am totally stuck and don't know
how to do it. Any help would be greatly appreciated.
Here is my scenario.
I have two forms, the main form called frmMTR and second form called
frmWarranty. I created a command button on the main form that when clicked it
will open the second form frmWarranty and copy some values form the main
form.
Here is the code I wrote; it does not work; it does not move the values.

Private Sub Export_Click()
'Opens frmWarrantyReport to populate some fields from frmMTR
'Dim stDocName As String
'Dim stLinkCriteria As String
'stDocName = "frmWarrantyReport"
'stLinkCriteria = "[DateReported]=" & "" & Me![DateReported] & ""
'stLinkCriteria = "[IssuedBy]=" & "" & Me![IssuedBy] & ""
'stLinkCriteria = "[MTRTitle]=" & "" & Me![MTRTitle] & ""
'DoCmd.OpenForm stDocName, , , stLinkCriteria
 
P

PUrvik

sylvieB25 said:
I need help with my forms in Access 2003. Basically my question is how to
move some values from one form to another. I am totally stuck and don't know
how to do it. Any help would be greatly appreciated.
Here is my scenario.
I have two forms, the main form called frmMTR and second form called
frmWarranty. I created a command button on the main form that when clicked it
will open the second form frmWarranty and copy some values form the main
form.
Here is the code I wrote; it does not work; it does not move the values.

Private Sub Export_Click()
'Opens frmWarrantyReport to populate some fields from frmMTR
'Dim stDocName As String
'Dim stLinkCriteria As String
'stDocName = "frmWarrantyReport"
'stLinkCriteria = "[DateReported]=" & "" & Me![DateReported] & ""
'stLinkCriteria = "[IssuedBy]=" & "" & Me![IssuedBy] & ""
'stLinkCriteria = "[MTRTitle]=" & "" & Me![MTRTitle] & ""
'DoCmd.OpenForm stDocName, , , stLinkCriteria
 
P

PUrvik

hi, Maurice,

I have a little problem about form in Access, You have a solution about that
proble,

Here is Problem, Im my Project I want to move one from field into another
form.
i have frmDonations is the main form , in this form i have a form feild
EmployeeID, i create one command Button called Last Year , which opens
LastYear From , which gives me last year information according
frmDonation-EmployeeID, but it not works,
i want to move frmDonation-EmployeeID into LastYEar Form- EmployeeID so, i
can fetch particular records from LastYEar table.


I need your Help,
I appreciate u.
 
M

Maurice

The situation you describe does need a filter. Show me the code you have so
far so I can see where the problem resides.

Behind the button you should have something like:

Private Sub OpenForm_Click
DoCmd.OpenForm "LastYear", acNormal, , "EmployeeID= " & EmployeeID

'if the employeeID doesn't exists you can push it forwarde to the form as
follows:

forms!LastYear!EmployeeID=me.employeeID
End sub

make sure to change the formnames and fieldnames in this example so that
they use your formname and fieldname.

If this doesn't fix it post your code here and we'll take a look at it.

hth
 
S

SylvieB

NEED HELP. how do you focus only on passing the fields of a record you're
looking at in the main form to another form? Thanks

Maurice said:
Sylvie,

Your code will try to filter the form based on your criteria. If i
understand correctly you want to push the data from some fields to the second
form.

Try this:
Private Sub Export_Click()

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmWarrantyReport"
DoCmd.OpenForm stDocName, , , stLinkCriteria
forms!frmWarrantyReport!DateReported=me!DateReported
forms!frmWarrantyReport!IssuedBy=me!IssuedBy
forms!frmWarrantyReport!MTRTitle=me!MTRTitle

docmd.close ("form1") '-> optional close the first form if you want...
end sub

This assumes that the fields on the second form have the same fieldnames as
the fieldnames on the first form.

hth
--
Maurice Ausum


sylvieB25 said:
I need help with my forms in Access 2003. Basically my question is how to
move some values from one form to another. I am totally stuck and don't know
how to do it. Any help would be greatly appreciated.
Here is my scenario.
I have two forms, the main form called frmMTR and second form called
frmWarranty. I created a command button on the main form that when clicked it
will open the second form frmWarranty and copy some values form the main
form.
Here is the code I wrote; it does not work; it does not move the values.

Private Sub Export_Click()
'Opens frmWarrantyReport to populate some fields from frmMTR
'Dim stDocName As String
'Dim stLinkCriteria As String
'stDocName = "frmWarrantyReport"
'stLinkCriteria = "[DateReported]=" & "" & Me![DateReported] & ""
'stLinkCriteria = "[IssuedBy]=" & "" & Me![IssuedBy] & ""
'stLinkCriteria = "[MTRTitle]=" & "" & Me![MTRTitle] & ""
'DoCmd.OpenForm stDocName, , , stLinkCriteria
 
M

Maurice

Sylvie,

Give me some more info on this one. You mean when the main form is open and
you open another form you want the current record of the main form pushed to
the newly opened form?
--
Maurice Ausum


SylvieB said:
NEED HELP. how do you focus only on passing the fields of a record you're
looking at in the main form to another form? Thanks

Maurice said:
Sylvie,

Your code will try to filter the form based on your criteria. If i
understand correctly you want to push the data from some fields to the second
form.

Try this:
Private Sub Export_Click()

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmWarrantyReport"
DoCmd.OpenForm stDocName, , , stLinkCriteria
forms!frmWarrantyReport!DateReported=me!DateReported
forms!frmWarrantyReport!IssuedBy=me!IssuedBy
forms!frmWarrantyReport!MTRTitle=me!MTRTitle

docmd.close ("form1") '-> optional close the first form if you want...
end sub

This assumes that the fields on the second form have the same fieldnames as
the fieldnames on the first form.

hth
--
Maurice Ausum


sylvieB25 said:
I need help with my forms in Access 2003. Basically my question is how to
move some values from one form to another. I am totally stuck and don't know
how to do it. Any help would be greatly appreciated.
Here is my scenario.
I have two forms, the main form called frmMTR and second form called
frmWarranty. I created a command button on the main form that when clicked it
will open the second form frmWarranty and copy some values form the main
form.
Here is the code I wrote; it does not work; it does not move the values.

Private Sub Export_Click()
'Opens frmWarrantyReport to populate some fields from frmMTR
'Dim stDocName As String
'Dim stLinkCriteria As String
'stDocName = "frmWarrantyReport"
'stLinkCriteria = "[DateReported]=" & "" & Me![DateReported] & ""
'stLinkCriteria = "[IssuedBy]=" & "" & Me![IssuedBy] & ""
'stLinkCriteria = "[MTRTitle]=" & "" & Me![MTRTitle] & ""
'DoCmd.OpenForm stDocName, , , stLinkCriteria
 
S

SylvieB

HI Maurice
Yes, that's correct. What do i need to change on the code?
Thank you

Maurice said:
Sylvie,

Give me some more info on this one. You mean when the main form is open and
you open another form you want the current record of the main form pushed to
the newly opened form?
--
Maurice Ausum


SylvieB said:
NEED HELP. how do you focus only on passing the fields of a record you're
looking at in the main form to another form? Thanks

Maurice said:
Sylvie,

Your code will try to filter the form based on your criteria. If i
understand correctly you want to push the data from some fields to the second
form.

Try this:
Private Sub Export_Click()

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmWarrantyReport"
DoCmd.OpenForm stDocName, , , stLinkCriteria
forms!frmWarrantyReport!DateReported=me!DateReported
forms!frmWarrantyReport!IssuedBy=me!IssuedBy
forms!frmWarrantyReport!MTRTitle=me!MTRTitle

docmd.close ("form1") '-> optional close the first form if you want...
end sub

This assumes that the fields on the second form have the same fieldnames as
the fieldnames on the first form.

hth
--
Maurice Ausum


:

I need help with my forms in Access 2003. Basically my question is how to
move some values from one form to another. I am totally stuck and don't know
how to do it. Any help would be greatly appreciated.
Here is my scenario.
I have two forms, the main form called frmMTR and second form called
frmWarranty. I created a command button on the main form that when clicked it
will open the second form frmWarranty and copy some values form the main
form.
Here is the code I wrote; it does not work; it does not move the values.

Private Sub Export_Click()
'Opens frmWarrantyReport to populate some fields from frmMTR
'Dim stDocName As String
'Dim stLinkCriteria As String
'stDocName = "frmWarrantyReport"
'stLinkCriteria = "[DateReported]=" & "" & Me![DateReported] & ""
'stLinkCriteria = "[IssuedBy]=" & "" & Me![IssuedBy] & ""
'stLinkCriteria = "[MTRTitle]=" & "" & Me![MTRTitle] & ""
'DoCmd.OpenForm stDocName, , , stLinkCriteria
 
M

Maurice

Hi Sylvie,

Pushing the data is depending on the current record you are presenting on
the first form. You push it as I described it in the previous post.

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmWarrantyReport"
DoCmd.OpenForm stDocName, , , stLinkCriteria
forms!frmWarrantyReport!DateReported=me!DateReported
forms!frmWarrantyReport!IssuedBy=me!IssuedBy
forms!frmWarrantyReport!MTRTitle=me!MTRTitle

This will fill the second form with the values from the main form. You have
to remember though that going back to the first form will not reset the
second form. The second form has to be closed and reopened first to get
refreshed.

If you want the second form to be open you could use a button on the second
form that pulls the data from the first form instead of pushing it.

Create a button an place the following code behind the button to retrieve
the data from the first form:

Private sub button1_click

me.textbox = forms!frmMTR!textbox
'repeat this for all te textboxes you want to fill...

end sub

me.textbox should be replaced by the textbox on your second form
forms!frmMTR!textbox -> this textbox should be replaced by the textbox on
your first form.

Now everytime you want to change the values open the secon form and click
the button to pull the data from the first form.

hth

--
Maurice Ausum


SylvieB said:
HI Maurice
Yes, that's correct. What do i need to change on the code?
Thank you

Maurice said:
Sylvie,

Give me some more info on this one. You mean when the main form is open and
you open another form you want the current record of the main form pushed to
the newly opened form?
--
Maurice Ausum


SylvieB said:
NEED HELP. how do you focus only on passing the fields of a record you're
looking at in the main form to another form? Thanks

:

Sylvie,

Your code will try to filter the form based on your criteria. If i
understand correctly you want to push the data from some fields to the second
form.

Try this:
Private Sub Export_Click()

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmWarrantyReport"
DoCmd.OpenForm stDocName, , , stLinkCriteria
forms!frmWarrantyReport!DateReported=me!DateReported
forms!frmWarrantyReport!IssuedBy=me!IssuedBy
forms!frmWarrantyReport!MTRTitle=me!MTRTitle

docmd.close ("form1") '-> optional close the first form if you want...
end sub

This assumes that the fields on the second form have the same fieldnames as
the fieldnames on the first form.

hth
--
Maurice Ausum


:

I need help with my forms in Access 2003. Basically my question is how to
move some values from one form to another. I am totally stuck and don't know
how to do it. Any help would be greatly appreciated.
Here is my scenario.
I have two forms, the main form called frmMTR and second form called
frmWarranty. I created a command button on the main form that when clicked it
will open the second form frmWarranty and copy some values form the main
form.
Here is the code I wrote; it does not work; it does not move the values.

Private Sub Export_Click()
'Opens frmWarrantyReport to populate some fields from frmMTR
'Dim stDocName As String
'Dim stLinkCriteria As String
'stDocName = "frmWarrantyReport"
'stLinkCriteria = "[DateReported]=" & "" & Me![DateReported] & ""
'stLinkCriteria = "[IssuedBy]=" & "" & Me![IssuedBy] & ""
'stLinkCriteria = "[MTRTitle]=" & "" & Me![MTRTitle] & ""
'DoCmd.OpenForm stDocName, , , stLinkCriteria
 

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