How to refer a control on a tabbed page over a form from other form or report

shah141

New member
Local time
Tomorrow, 03:16
Joined
May 6, 2012
Messages
4
Hello guys!
I have a form 'Op_Data' to enter my operation data. It has got a tab control 'TabCtrOpInfo' over which there are 4 pages; 'Basic Info', 'Details', 'PoOrdComp' and 'PostOp'.
Over page 'Basic Info', there are multiple controls, of which there are two controls of my interest at moment. They are 'OpCharges' and 'Operation'.
On page 'Details', there is a control 'op_detail' and on page 'PoOrdComp' there is a control 'PostOpOrders'.
There is another form 'Adm_Trt' that has a Command Button 'Operation' that will open form 'Op_Data' on click. This Command Button has following code in its ‘on click’ event;
Private Sub Command_Operation_Click()
DoCmd.OpenForm "Op_Data", acNormal, "", "[AdmID]=" & ID, , acNormal
DoCmd.Maximize
If [Form_Op_Data].NewRecord Then
With [Form_Op_Data]
.HistoryID = Me.HistoryID
.Operation = Me.Operation.Column(1)
.OpCharges = Me.Operation.Column(2)
.op_detail = Me.Operation.Column(3)
.PostOpOrders = Me.Operation.Column(4)
End With
End If
DoCmd.Close acForm, "Adm_Trt", acSavePrompt
End Sub
On clicking Command Button, controls present on 1st page ‘Basic Info’ of tab control 'TabCtrOpInfo' on form ‘Op_Data’ are updated but controls on page ‘Details’ and page 'PoOrdComp' remain empty, without any change. I could not understand that where is the problem..

Please help me
 
First off, do not name your page DETAILS as that is an Access Reserved Word and has special meaning on a form. You can have the CAPTION say DETAILS but your page name should be something like pgeDetails so Access is not confused thinking you want the details section of the form.

For referring to controls on a tab control, you do not need to refer to them any different than if the tab control was not there. So, if I have a control named cboItem, and I have no tab control, I would refer to it using Me.cboItem, and when it is on a tab control page, I would still refer to it as Me.cboItem. No difference.


Second, your code uses:
If [Form_Op_Data].NewRecord Then

which is incorrect syntax. It should be

If Forms!Op_Data.NewRecord Then

And

With [Form_Op_Data]

should be

With Forms!Op_Data
 

Users who are viewing this thread

Back
Top Bottom