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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse code for pointing and dragging to assign values 1

Status
Not open for further replies.

TheTeaMan

Technical User
Jun 26, 2007
14
US
I posted this question in the Form thread. since I did not any response from others, I am wondering if I had placed the question in the right thread. Here is the question:
I have a form that has many check boxes (approx 76.) I would like to see if there is a way to point the mouse to one corner and drag it to go over many boxes (as desirable) in which the value of theses boxes to be changed (checked or unchecked). I know on windows’ desktop if you point and drag the mouse over so many icons, you are basically able to select them all at once. This is kind of the same principle that I would like to achieve.
Any help on how to do this is greatly appreciated.
 
Seventy-six checkboxes makes me suspect the table has not been normalized. You cannot select checkboxes in this fashion with VBA, however, you could set the tag property to say, a number, and provide the user with a means of entering a range, 1-50, for example, which could then be used to iterate through the form and select the checkboxes in the range.
 
Remou,
Thanks for the reply, however, withought going into much detail my Form works perfect and my data has been normalized. I have checkboxes made for the user to check to indicate whether they each task is completed or not during his/her shift. We have no issues whatsoever with a form that has 76 checkboxes.
Back to the mouse question does anyone have any idea on how to accompish what I need?
Thanks
 
TheTeaMan,
Here is a roughly coded concept.
Code:
Private blnMoving As Boolean

Private Sub Detail_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
blnMoving = True
Me.Box0.Visible = True
Me.Box0.Top = Y
Me.Box0.Height = 0
Me.Box0.Left = X
Me.Box0.Width = 0
End Sub

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If blnMoving Then
  Me.Box0.Height = Y - Me.Box0.Top
  Me.Box0.Width = X - Me.Box0.Left
End If
End Sub

Private Sub Detail_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
ToggleChecksInBox
blnMoving = False
Me.Box0.Visible = False
End Sub

Sub ToggleChecksInBox()
Dim ctlCurrent As Control
For Each ctlCurrent In Me.Controls
  If TypeName(ctlCurrent) = "Checkbox" Then
    If ctlCurrent.Top >= Me.Box0.Top And _
    ctlCurrent.Top <= (Me.Box0.Top + Me.Box0.Height) Then
      If ctlCurrent.Left >= Me.Box0.Left And _
      ctlCurrent.Left <= (Me.Box0.Left + Me.Box0.Width) Then
        ctlCurrent.Value = Not ctlCurrent.Value
      End If
    End If
  End If
Next ctlCurrent
End Sub

I think you try this route you will need to be prepared to write a lot of error handling...

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
CautionMP,
Thank you very much. It worked very well. That exactly what I wanted to do. You are great.
Thank you again....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top