Access - Modify VBA Code for a Toggle Button

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
I have some code for a Toggle button I want to slightly modify

HEre is the Code
Code:
Private Sub ToggleBid_Click()

DoCmd.RunSQL ("UPDATE tblNavigation SET tblNavigation.Toggle_condition = True WHERE (((tblNavigation.Bid_tracker)='YES'));")

End Sub

I need code that basically says If ToggleBid = True Then ....... I don't want to tie it to the Click of the actual Toggle. I have three other Toggles that basically do exactly the same with the exceptions of the field tblNavigation.Bid_tracker

tblNavigation.Task_tracker
tblNavigation.BOE_tracker
tblNavigation.Cost_tracker

I am trying to convert this so with a Click of a button it runs through all four instead of one at a time, but the condition would still be if the associated toggles (ToggleBid, ToggleTask, ToggleBOE & ToggleCost) = True

Thanks
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Can't you just put the code in the Click event of the button?
Code:
Private Sub CommandButton1_Click

    If ToggleBid.Value = True Then
        DoCmd.RunSQL ("UPDATE tblNavigation SET tblNavigation.Toggle_condition = True WHERE (((tblNavigation.Bid_tracker)='YES'));")
    End If


    If Toggle.Task_tracker.Value = True Then
        ' do something
    End If

    ' and so on for the rest of the toggle buttons

End If
 
Upvote 0

Forum statistics

Threads
1,221,687
Messages
6,161,289
Members
451,695
Latest member
Doug Mize 1024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top