Copy and Paste data between two forms

NadiaVKhan

Registered User.
Local time
Today, 11:05
Joined
Mar 8, 2017
Messages
27
Hello.

I have two forms. frmAlpha and frmBeta.

There is a button on frmAlpha that opens frmBeta in a dialogue box. I want this button to ALSO copy the data in field txtFoodNameA in frmAlpha to txtFoodNameB in frmBeta.

What is the code I would use for this?

I imagine it should be something along the lines of

Sub
frmAlpha.txtFoodNameA.value = frmBeta.txtFoodNameB.value
End Sub
 
Is this a New Record in frmBeta? If so, you can use the OpenArgs argument, like this, where AlphaButtonName is the actual name of your Command Button:

In Form frmAlpha:

Code:
Private Sub AlphaButtonName_Click()
  DoCmd.OpenForm "frmBeta” , , , , , Me.txtFoodNameA	
End Sub
Then, in frmBeta:

Code:
Private Sub Form_Load()
  If Nz(Me.OpenArgs, "") <> "" Then
    DoCmd.GoToRecord , , acNewRec
    Me.txtFoodNameB = Me.OpenArgs
  End If
End Sub
Linq ;0)>
 
Yes. It is a new record in frmBeta. However, I recieve a "Run-Time error '13': type mismatch" error when I click the button on frmAlpha
 
Sorry...missed a comma, I think! Instead of

DoCmd.OpenForm "frmBeta” , , , , , Me.txtFoodNameA

try

DoCmd.OpenForm "frmBeta” , , , , , , Me.txtFoodNameA

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom