473,387 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help with Check Box code

Hi there,

I am having much difficulty with what is probably a very simple
problem.

I have multiple check boxes, named Check1 to Check10. I would like
the code to run macros associated with each checkbox by using the
checkbox tag.

i.e. Check1.tag = CUSTMR
if Check1 = -1 then
runMacro "Update" & Check1.tag

Any help will be much appreciated.
Private Sub UpdateButton_Click()
Dim CheckCount As Integer
Dim strCheckName As String
Dim strCheckNameTag As String
Dim strCheckMacro As String

CheckCount = 1

Do While CheckCount < 11

strCheckName = "Me.Check" & CheckCount
strCheckNameTag = strCheckName & ".Tag"
strCheckMacro = "Update & " & strCheckNameTag

If strCheckName = -1 Then
DoCmd.RunMacro strCheckMacro

End If
CheckCount = CheckCount + 1
Loop
End Sub
Nov 13 '05 #1
4 1395
Well, not sure I would do it that way, but don't see why it shouldn't work.
When is this code started? - on the form's OnOpen, theCheck# AfterUpdate,
etc.. What results/errors are you getting?
-Ed

"Nathan Bloomfield" <na**************@hotmail.com> wrote in message
news:4b*************************@posting.google.co m...
Hi there,

I am having much difficulty with what is probably a very simple
problem.

I have multiple check boxes, named Check1 to Check10. I would like
the code to run macros associated with each checkbox by using the
checkbox tag.

i.e. Check1.tag = CUSTMR
if Check1 = -1 then
runMacro "Update" & Check1.tag

Any help will be much appreciated.
Private Sub UpdateButton_Click()
Dim CheckCount As Integer
Dim strCheckName As String
Dim strCheckNameTag As String
Dim strCheckMacro As String

CheckCount = 1

Do While CheckCount < 11

strCheckName = "Me.Check" & CheckCount
strCheckNameTag = strCheckName & ".Tag"
strCheckMacro = "Update & " & strCheckNameTag

If strCheckName = -1 Then
DoCmd.RunMacro strCheckMacro

End If
CheckCount = CheckCount + 1
Loop
End Sub

Nov 13 '05 #2
Commentary interspersed...

On 26 Jan 2005 16:22:14 -0800, na**************@hotmail.com (Nathan
Bloomfield) wrote:
Hi there,

I am having much difficulty with what is probably a very simple
problem.

I have multiple check boxes, named Check1 to Check10. I would like
the code to run macros associated with each checkbox by using the
checkbox tag.

i.e. Check1.tag = CUSTMR
if Check1 = -1 then
runMacro "Update" & Check1.tag

Any help will be much appreciated.

- Some indentation would amke this code easier to read
and maintain.Private Sub UpdateButton_Click()
Dim CheckCount As Integer
Dim strCheckName As String
Dim strCheckNameTag As String
Dim strCheckMacro As String

CheckCount = 1

Do While CheckCount < 11 - A "For" loop would be simpler.
strCheckName = "Me.Check" & CheckCount - Me refers to the object module in which the VBA code is running.
it means nothing to the macro code. You can refer to a control
by name using the form's Controls collection -
Me.Controls("Check" & CheckCount)strCheckNameTag = strCheckName & ".Tag"
strCheckMacro = "Update & " & strCheckNameTag - I don't know what the Update macro does, but couldn't you do it
in VBA code?
If strCheckName = -1 Then
DoCmd.RunMacro strCheckMacro

End If
CheckCount = CheckCount + 1
Loop
End Sub


Nov 13 '05 #3
I almost forgot...

....

If strCheckName = -1 Then
DoCmd.RunMacro strCheckMacro

End If


strCheckName is the fully qualified name of the control that you assigned
earlier. The string will always equal that name-text, never a value from the
control.
Nov 13 '05 #4
Thanks Steve, that was very helpful.

I have changed my approach and am now using a recordset based on a
table rather than the checkbox approach.
Your advice allowed me to pursue the task further.

Regards,
Nathan

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
9
by: YZK | last post by:
Hello. I'm not a Web developer, just a user, and I think I may have somehow messed myself up majorly. I'm not quite sure how. Right now, javascript used by websites I go to either does not work at...
1
by: Pax S | last post by:
I need a button that will check (make true) two check boxes (fields) For the record that has the focus (the record on the form that I am presently looking at). The two check boxes would be like a...
5
by: John | last post by:
I am new in Regular Expression. Could someone please help me in following expression? 1. the string cannot be empty 2. the string can only contains AlphaNumeric characters. No space or any...
3
by: inkexit | last post by:
I need help figuring out what is wrong with my code. I posted here a few weeks ago with some code about creating self similar melodies in music. The coding style I'm being taught is apparently a...
4
by: Gary | last post by:
Hello, I'm hoping someone can shed some light on why my report does not output the same results as shown in preview mode, which is to move the position of a check box based on a field value (see...
1
by: Unebrion | last post by:
Alright im working on a program that prints out user imput in a frame, along with a barcode.. it is like the front of an envelope. Here is the description for the program. This...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
6
by: priyajohal | last post by:
#include<fstream.h> #include<process.h> #include<stdlib.h> #include<conio.h> #include<string.h> #include<dos.h> #include<ctype.h> #include<stdio.h> void setup() void help();
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.