Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmatically change DataEntry, Addition, etc. 1

Status
Not open for further replies.

ColdDay

Technical User
Nov 30, 2010
92
US
I am trying to change the Data Entry, Addition, Deletion and Edit settings of a form (frm_aaa_TabbedPagesPractice) programmatically. This form has a Tab Control with the following four tab pages:

Page Name Page Index
Add/Main 0
Edit/Delete 1
Reports/Charts 2
Tables 3

The form opens OK from design view to form view on any of the pages, but when I click on one of the tabs in form view, I get the message that the “Object does not support this property or method.” Following is the code I am currently trying to use. I know I will need to set my “Allows…” to either true or false depending on my requirements, but I am not yet able to get the code to work to see how I want to set them.


Code:
Private Sub tab_Pages_Change()
Dim frm As Form
'With frm
If Forms("frm_aaa_TabbedPagesPractice").Controls("tab_Pages").PageIndex = 0 Then
    With frm
        .AllowDataEntry = False
        .AllowAdditions = False
        .AllowDeletions = False
        .AllowEdits = False
    End With

ElseIf Forms("frm_aaa_TabbedPagesPractice").Controls("tab_Pages").PageIndex = 1 Then
    With frm
  	.AllowDataEntry = False
.AllowAdditions = False
        	.AllowDeletions = False
        	.AllowEdits = False
    End With

ElseIf Forms("frm_aaa_TabbedPagesPractice").Controls("tab_Pages").PageIndex = 2 Then
    With frm
.AllowDataEntry = False
        .AllowAdditions = False
        .AllowDeletions = False
        .AllowEdits = False
    End With
    
ElseIf Forms("frm_aaa_TabbedPagesPractice").Controls("tab_Pages").PageIndex = 3 Then
    With frm
	.AllowDataEntry = False
        .AllowAdditions = False
        .AllowDeletions = False
        .AllowEdits = False
    End With
End If
'End With
End Sub

If there is a better/easier way to do this or if I am way off base, please let me know. Any help will be appreciated.

Thanks.
 
How are ya ColdDay . . .

Your biggest problem is you dim a form object ...
Code:
[blue]   Dim frm As Form[/blue]
... but you don't assign a form object to it, something like:
Code:
[blue]   Set frm = Forms!frm_aaa_TabbedPagesPractice[/blue]
You don't need it anyway. Try the following:
Code:
[blue]   Dim TC As TabControl
   
   Set TC = Me.tab_Pages
   
   With Me
      .DataEntry = Choose(TC, False, False, False, False)
      .AllowAdditions = Choose(TC, False, False, False, False)
      .AllowDeletions = Choose(TC, False, False, False, False)
      .AllowEdits = Choose(TC, False, False, False, False)
   End With[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Woops ... correction below [blush]
Code:
[blue]   Dim TC As TabControl, Pg As Integer
   
   Set TC = Me.TabCtl38
   Pg = TC + 1
   
   With Me
      .DataEntry = Choose(Pg, False, False, False, False)
      .AllowAdditions = Choose(Pg, False, False, False, False)
      .AllowDeletions = Choose(Pg, False, False, False, False)
      .AllowEdits = Choose(Pg, False, False, False, False)
   End With[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top