[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Tick all visible tick boxes

Posted on 2011-05-03
5
Medium Priority
?
323 Views
Last Modified: 2012-05-11
I have a form with a tab control on it with a number of tick boxes on each page. I am trying to get a cmd button to tick all tick boxes but only those that are visible i.e. if I am viewing page 1 and I click the button then all the check boxes become ticked on page one without effecting page 2 or 3

The code I have so far is below but it keeps throwing up error 13 type mismatch on the line

Set pagCurrent = tabCtl.Pages

I am reasoning that I am referencing the current page wrongly. I like to get the code working so any suggestions to get it going would be well recieved.

Regards

Mal
Private Sub CmdAddTicks_Click()
'Enable Error Start
'    On Error GoTo PROC_ERR
ChangeTicks (-1)
    'Handle Error Start
PROC_EXIT:
    Exit Sub
    
PROC_ERR:
    Call ErrorLog(Err.Description, Err.Number, Me.Name)
    Resume PROC_EXIT
End Sub

-----------------------------------------------------------------------------------

Private Sub CmdRemoveTicks_Click()
'Enable Error Start
    On Error GoTo PROC_ERR
ChangeTicks (0)
    'Handle Error Start
PROC_EXIT:
    Exit Sub
    
PROC_ERR:
    Call ErrorLog(Err.Description, Err.Number, Me.Name)
    Resume PROC_EXIT
End Sub

Private Sub ChangeTicks(NewVal As Integer)

Dim tabCtl As TabControl
Dim pagCurrent As Page
Dim ctlCurrent As Control
Dim intPageNum As Integer

'Enable Error Start
'    On Error GoTo PROC_ERR

Set tabCtl = Me.TabForm
Set pagCurrent = tabCtl.Pages
For Each ctlCurrent In pagCurrent.Controls
  If ctlCurrent.ControlType = acCheckBox Then
    intPageNum = intPageNum + 1

    x(intPageNum) = ctlCurrent.Name & " = " & NewVal & ""
  End If
Next ctlCurrent
    
    'Handle Error Start
PROC_EXIT:
    Exit Sub
    
PROC_ERR:
    Call ErrorLog(Err.Description, Err.Number, Me.Name)
    Resume PROC_EXIT
End Sub

Open in new window

0
Comment
Question by:MGardner
  • 2
  • 2
5 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35517330
You defined "pagCurrent" as a Page, singular, but you are trying to assign "tabCtl.Pages", plural. "Pages" represents all the pages on the "tabCtl" tab. You just need to refer to the active one.
0
 
LVL 10

Expert Comment

by:ALaRiva
ID: 35517356
Try this...

Dim ctl As Control

With Me.tabCtl
For Each ctl in .Pages(.Value).Controls
   If TypeOf ctl Is acCheckBox Then 
      ctl.Value = True
   End If 
Next ctl
End With

Open in new window

0
 
LVL 2

Author Comment

by:MGardner
ID: 35517503
Hi Kaufmed - a silly mistake but it is now showing it as a compile error i.e.method or data memeber not found?

ALaRiva your code dosn't work for me as it needs to be able to take the new value from the change ticks?

0
 
LVL 10

Accepted Solution

by:
ALaRiva earned 2000 total points
ID: 35517575
So just change this line...
ctl.Value = True

to this...
ctl.Value = NewVal
0
 
LVL 2

Author Closing Comment

by:MGardner
ID: 35687725
Many thanks works a treat
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question