Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / February 2005

Tip: Looking for answers? Try searching our database.

Need VBA assistance for check boxes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brent E - 03 Feb 2005 23:47 GMT
Good afternoon,

I am using a VBA module to open an Access form. Form contains several check
boxes (made is design view, not created by code) to offer a user to select
which documents they would like to print, but
I need to know what VBA commands to use that will tell if a check box is
checked or not. I set a command button called "Print Selection" to run code
that I want to print out any documents selected. (See code below) And
procedure will compile and run, and the form opens but if I check box 29,
nothing prints in the immediate window no matter if box is checked or not. I
am curoius if I have to refresh my form or anything after that opens and I
check a box?

I think What I need to know is how to reference the checkboxes on the form,
and if they should automatically sense a change in state, or do I need to do
something for them to sense a change in state on the form? (Note check29 is
name of checkbox on form) This is my code:

DoCmd.OpenForm "Graphs Print Selection", acNormal, "", "", , acNormal
       If Check29 = True Then
       Debug.Print "29"
       Else
END If

Do I need to use a Me.Check29 or a get command to refresh box, or how does
this know that a box is checked? What am I doing wrong? Thanks.

Cordially,
Douglas J. Steele - 04 Feb 2005 00:14 GMT
Yes, you should use Me.Check29.

I'm not quite sure what you have in mind by "automatically sense a change in
state". In general, you put code in the checkbox's AfterUpdate event if you
want something to happen when the status of the checkbox changes.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Good afternoon,
>
[quoted text clipped - 30 lines]
>
> Cordially,
Dan Artuso - 04 Feb 2005 00:23 GMT
Hi,
You don't need to refresh your form or anything.
Your if statement should work if your box is checked.

Just to be clear, the code below is running within the form that
has your checkbox, right? You're not trying to interrogate a checkbox
that's on the form your code opens, right?

Try setting a breakpoint to see what happens as you step through the code.

--
HTH
Dan Artuso, Access MVP

> Good afternoon,
>
[quoted text clipped - 24 lines]
>
> Cordially,
Marshall Barton - 04 Feb 2005 00:30 GMT
>I am using a VBA module to open an Access form. Form contains several check
>boxes (made is design view, not created by code) to offer a user to select
[quoted text clipped - 20 lines]
>Do I need to use a Me.Check29 or a get command to refresh box, or how does
>this know that a box is checked? What am I doing wrong? Thanks.

You are suffering from a major misperception.  Primarily
that your code module procedure is synchronous with the
form.  Once you execute the OpenForm method, your code loses
control of the form.

All the code associated with actions on the form need to be
in the form's event procedures.  In this case, you don't
care when if a user sets or clears a check box.  (If you did
care, each check box's AfterUpdate event will notify you
about the value changing).  You can perform whatever
activities you need for each check box (as your code does
now) in the command button's Click event procedure.

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.