My subcode wont work when my checkbox is checked

  • Thread starter Thread starter Dams76
  • Start date Start date
D

Dams76

I am creating a form with about 20 check boxes on it and one button.
Each checkbox will represent a query that needs to be run. So the user
will select multiple checkboxes and then press the execute button to
run the selected queries. I have my execute button set up with an On
Click evet. It calls a Macro and the Macro's action is RunCode.and
the function name is Click()

In Module 2 is the following code that is being called:

Public Function Click()
Call Module1.Command6_Click1
End Function

Here is the code in Module1

Public Sub Command6_Click1()
If CheckBox38 = Checked Then
MsgBox "Box checked."
Else
MsgBox ("Box NOT checked.")
End If
End Sub

The problem is everytime I click on the execute button it completely
ignores if the checkbox is checked or not. What I mean by this is
wether the checkbox is checked or not I always get the "Box NOT
checked" message box. I know this is probably just a simple error on
my part, but I am tearing my hair out trying to figure out the answer.
Thank you in advance for you help with this issue.
DavidS
 
this is probably a tangential answer, but what happens if you decide
later on that you have other queries that should be run? If you store
the queries in a table or can create a multiselect listbox to show them
to the user, then the user can click on the ones he wants and process
them all in one go. I did that with a database with something like 800
queries and it worked a charm. The user could add queries to his
heart's content and choose which ones he wanted to run. Just use the
ItemsSelected collection of the listbox.
 
I can do that, but wouldnt know how to implement it. Also The entire
Access database is already created and no new queries will need to be
added to the 30 or so that are already created. What I am trying to
fix is the fact the user has to click on a button for each query that
they want to run and wait for it to finish before they can run the next
query. All the queries just append data to a single table. So it
would make more sense to have them select all the queries that need to
be run and then click on one button to execute all the quereis at once.
I thought using checkboxes would be the best way, but cant seem to
figure out why my code isnt working correctly.
 
Back
Top