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!

Change Toggle Button(s) State 1

Status
Not open for further replies.

dkmansion

Technical User
Joined
Feb 24, 2005
Messages
32
Location
US
I have a single Toggle button (tglMultipleTransactions) that I would like to control 20 other toggle buttons on a form( the other buttons make a change to the DefaultValue property for individual fields on a form to copy to a NewRecord for ease of multiple entries)

I am stumped as to how to code the event to turn on then turn off when the state of (tglMultipleTransactions) changes.

My code...
Code:
Private Sub tglMultipleTransactions_BeforeUpdate(Cancel As Integer)
    Dim proceed As Boolean
   If Me!tglMultipleTransactions = False Then
                'Would You Like to Turn On?
        proceed = MsgBox("Do you want to set fields to copy to new records?", _
        vbYesNo, "Copy for Multiple Transactions?")
            If proceed = vbYes Then
                'Turn On
                Me!tglCompanyID.Value = True
etc
etc
            Else
                'Leave Alone
            End If
    Else

            'Would you like to turn off?
        proceed = MsgBox("Do you want to remove the set fields to copy to new record function?", _
        vbYesNo, "Remove Copy for Multiple Transactions?")
            If proceed = vbYes Then
                'Turn Off
                Me!tglCompanyID.Value = False
                Me!tglEISRNumber.Value = False
etc
etc
etc
            Else
                'Leave Alone
            End If
    End If
End Sub

Thanks in advance for your time..

Donald M
 
Here is the correct code, which works...

Code:
Private Sub tglMultipleTransactions_BeforeUpdate(Cancel As Integer)
   Dim proceed As Integer
   If Me!tglMultipleTransactions = False Then
        'Would You Like to Turn On?
        proceed = MsgBox("Do you want to set fields to copy to new records?", _
        vbYesNo, "Copy for Multiple Transactions?")
            If proceed = vbYes Then
                'Turn On
                Me.tglCompanyID = True
                Me.tglEISRNumber = True
            Else
                'Leave Alone
            End If
    Else
        'Would you like to turn off?
        proceed = MsgBox("Do you want to remove the set fields to copy to new record function?", _
        vbYesNo, "Remove Copy for Multiple Transactions?")
            If proceed = vbYes Then
                'Turn Off
                Me.tglCompanyID = False
                Me.tglEISRNumber = False
            Else
                'Leave Alone
            End If
    End If
End Sub

Dim proceed As Boolean - This is wrong
Since mesgbox Response for VbYesNo returns an Integer
It should be declared as
Dim proceed As Integer

Hope this helps you...
Regards,
 
Thanks HOA much appreciated.

Donald M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top