Referencing an item inside a tab control

miken5678

Registered User.
Local time
Today, 13:20
Joined
Jul 28, 2008
Messages
113
I have tried to find something on the web but maybe I am not searching for the right term(s).

I basically setup a .visible logic statement driven off of one field when it is yes or -1.

This works perfectly so I cut and pasted into the tab. Needless to say it doesnt work anymore. I even cut and paste the item back on the main form and it doesnt work.

Prior issues with a split form required me changing names from

me.fieldname to
forms!windoptoutv12.fieldname

Is there some sort of difference in noting a field once it is inside the tab?

the name of the whole tab box is tabctl207 and the tabs inside are invidivual and entity.

First Version - this worked fine outside of the tab and after cutting and pasting it no longer works.
Public Function OtherFunction()
If Forms!WindOptOutV12.Other = -1 Then
Forms!WindOptOutV12.IndStatmentHandwrittenComment.Visible = True
'MsgBox "Please Enter a Comment Below for Deviations listed as OTHER"
Else
Forms!WindOptOutV12.IndStatmentHandwrittenComment.Visible = False
Forms!WindOptOutV12.IndStatmentHandwrittenComment = "None"
End If
End Function
 
The tab is not a part of the syntax required to reference the control. Is there really a space before the word "Visible"? There shouldn't be.
 
The tab is not a part of the syntax required to reference the control. Is there really a space before the word "Visible"? There shouldn't be.


I think that is just the way that it copied over.

i have attached it and it is version 12.
 

Attachments

I figured this one out.. seems cut and paste removed any relation to event type for those fields that were cut for my before/after update. Not sure if this cuts the reference for all types but once I put them back in it works fine now... a bug or not sure a pain in the butt
 
The code appears to run without error for me. What is the problem?
 
Cutting and pasting a control from a main form to a tabbed page does, indeed, 'break' the Event Procedures attached to the control, and it has to be 're-attached' if you will.

For a few controls you can simply do as you have, clicking on the event in the Properties pane, going to the code then back to Design View, and the event will be 're-attached."

If you have a number of controls, you can use something like this code, which will "reconnect" controls to some selected Events (OnClick and AfterUpdate in this example.) It can be modified for other Events, and has the advantage of updating a large number of controls without doing them one by one.

Code:
Private Sub Form_Load()
Dim ctl As Control

For Each ctl In Me.Controls
If (TypeOf ctl Is TextBox) Or (TypeOf ctl Is ComboBox) Then
If ctl.OnClick = "" Then
ctl.OnClick = "[Event Procedure]"
End If
End If
Next

For Each ctl In Me.Controls
 If (TypeOf ctl Is TextBox) Or (TypeOf ctl Is ComboBox) Then
   If ctl.AfterUpdate = "" Then
     ctl.AfterUpdate = "[Event Procedure]"
   End If
 End If
Next
End Sub
This code should be credited to ADezii of another Access forum.

Linq ;0)>
 
thank you for that.. a time saver it is.. i was going towards setting everything to onclick until i noticed that the event procedure wasnt there.. i guess i can understand the actions esp if you cut it just glad I found it as it was making me silly
 

Users who are viewing this thread

Back
Top Bottom