passing values between forms

G

Guest

oI have two forms. On form1, when the user clicks on a button, it stores the
current value of three fields, duplicates the record, and form2 would pop up.
There are three textboxes on form2, which is populated with data from the
form1. If the user changes the value of the textbox and then clicks on the
button, I would like the value of the text boxes passed back to form1. After
it is passed back, I want to compare a field from form2 and form1 to see if
it is the same. If it is not the same, then the record from form1 would be
appended to another table. Does anyone have any ideas how I can pass the
value from form1 to form2, make any changes neccessary, and then back to
form1 and have it run through the code in form1? Any help is appreciated.

Thanks.
Ash
 
G

Guest

To pass values from form1 to form two, have a look at "form opening
arguments" in Access Database Programming.
To pass back values from form2 to form1 try this
Forms![Form1Name]![FieldName] = me.[FieldName]

And to compare between the two fields, just change the equal sign to <>
IF Forms![Form1Name]![FieldName] <> me.[FieldName] Then
 
G

Guest

I can't seem to get it right. It seems a little more complicated then that.

This is what I have:

form 1
private sub cmd_duplicate_click()
msg = "Do you want to duplicate this record?"
style = vbYesNo
response = MsgBox(msg, style)
If response = vbYes Then
code to duplicate main form, subforms data

DoCmd.OpenForm stDocName, , , , , , curREVISION
(code at the bottom)

when user changes the revision letter on form 2, I want that value to be
passed here.
end if
If Forms!frm_duplicate.TXT_REVISION <> curREVISION Then
code to append the data to a table
end if
end sub


form 2 opens
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me.TXT_REVISION = Forms!FRM_MAIN_PARTS_LIST.REVISION
End If
End Sub

Private Sub CMD_CLOSE_Click()
Forms!FRM_MAIN_PARTS_LIST.REVISION = Me.TXT_REVISION
DoCmd.Close
End Sub



Ofer said:
To pass values from form1 to form two, have a look at "form opening
arguments" in Access Database Programming.
To pass back values from form2 to form1 try this
Forms![Form1Name]![FieldName] = me.[FieldName]

And to compare between the two fields, just change the equal sign to <>
IF Forms![Form1Name]![FieldName] <> me.[FieldName] Then


ash said:
oI have two forms. On form1, when the user clicks on a button, it stores the
current value of three fields, duplicates the record, and form2 would pop up.
There are three textboxes on form2, which is populated with data from the
form1. If the user changes the value of the textbox and then clicks on the
button, I would like the value of the text boxes passed back to form1. After
it is passed back, I want to compare a field from form2 and form1 to see if
it is the same. If it is not the same, then the record from form1 would be
appended to another table. Does anyone have any ideas how I can pass the
value from form1 to form2, make any changes neccessary, and then back to
form1 and have it run through the code in form1? Any help is appreciated.

Thanks.
Ash
 

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