Copy a value of a control on a mainform to a control on a subform.

2

2vao

Hello,

I have a MainFrm that has a control called RmgID (Autonumber ), on my SubFrm
I have Yes/No control called RmAssg and a txtbox called RmgID1.

I would like after updating RmAssg, if RmAssg is True then RmgID is copied
to RmgID1
This is what I tried but nothing happened:
Private Sub RmAssg_AfterUpdate()

If Me.RmAssg = True Then
Me.RmgID1.Value = Me![RmgID]
Else
Me.RmgID1.Value = 0
End If
Exit_RmAssg_AfterUpdate:
Exit Sub
Err_Handler:
MsgBox " Error '" & Err.Number & "' " & Err.Description
Resume Exit_RmAssg_AfterUpdate
End Sub
( I tried putting that code on after update of the control and of the form
but nothing happened )

what I am trying to achieve is to get the value of RmgId copied to RmgID1
only for the records on the subform where RmAssg is true,
Many thks.
 
W

Wayne-I-M

Private Sub RmAssg_AfterUpdate()
If Me.RmAssg = -1 Then
Me.RmgID1 = Forms!MainFormName!RmgID
Else
Me.RmgID1 = 0
End If
End Sub

Change MainFormName to what it really is
 
2

2vao

Thank you so much Wayne for your quick reply and for correcting my code. It
is working.
Cheers.

Wayne-I-M said:
Private Sub RmAssg_AfterUpdate()
If Me.RmAssg = -1 Then
Me.RmgID1 = Forms!MainFormName!RmgID
Else
Me.RmgID1 = 0
End If
End Sub

Change MainFormName to what it really is

--
Wayne
Trentino, Italia.



2vao said:
Hello,

I have a MainFrm that has a control called RmgID (Autonumber ), on my SubFrm
I have Yes/No control called RmAssg and a txtbox called RmgID1.

I would like after updating RmAssg, if RmAssg is True then RmgID is copied
to RmgID1
This is what I tried but nothing happened:
Private Sub RmAssg_AfterUpdate()

If Me.RmAssg = True Then
Me.RmgID1.Value = Me![RmgID]
Else
Me.RmgID1.Value = 0
End If
Exit_RmAssg_AfterUpdate:
Exit Sub
Err_Handler:
MsgBox " Error '" & Err.Number & "' " & Err.Description
Resume Exit_RmAssg_AfterUpdate
End Sub
( I tried putting that code on after update of the control and of the form
but nothing happened )

what I am trying to achieve is to get the value of RmgId copied to RmgID1
only for the records on the subform where RmAssg is true,
Many thks.
 

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