Copy Value

L

Luis

Hi
If I've 02 different forms base on 02 different tables not linked and I need
to copy one value of one in the other one.
Example:
FrmAgent.IDAgent & FrmComm.IDComm
Normally I do smething like:
After Update: Me.IDComm.Value=Me.IDAgent.Column(0)
What I need is the instruction in VBA to order the same but the problem is
that the forms have no connection or link at all!
Thanks and greeting s from Italy
 
G

GeoffG

It's possible, but you need to be sure that what you're doing is
sensible. It seems the user will need to concentrate not to make
a mistake (e.g. by copying a value to the wrong record showing on
FrmAgent).

Here's a code example for the Click event of a Copy command
button on FrmComm that will copy the value in the txtID TextBox
on FrmComm to the txtID TextBox on the FrmAgent:

Private Sub cmdCopy_Click()

' Name of form to copy to:
Const strcFormName As String = "FrmAgent"

' See if other form is open:
If CurrentProject.AllForms(strcFormName).IsLoaded Then
Forms(strcFormName).txtID = Me.txtID.Value
Else
MsgBox "Cannot copy ID." & vbNewLine _
& "The form " & strcFormName & " isn't loaded.", _
vbExclamation + vbOKOnly, _
"Copy Aborted"
End If

End Sub


Geoff
 

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