Solved

Form option group

Posted on 2013-01-18
5
382 Views
Last Modified: 2013-01-18
Hi guys,

I have a form option group named opt_group1 including 2 check boxes named check1 and check2.
On a report I have 2 labels named label1 and label2.
I would like to have the label1 visible and label 2 non-visible when I check the check1, the label2 visible and label1 non-visible when I check the check2 and no label visible when no check box is checked.
Can anyone please tell me how to do this?
Thank you
0
Comment
Question by:marian68
  • 2
  • 2
5 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 335 total points
ID: 38793362
Your option group has values associated with each of those checkboxes, which determine the overall value of the option group.  Double-check those values, and adjust this code which should be placed in the Report's Detail Format event:


Private Sub Detail_Format()

If IsNull(Forms!YourFormName.opt_group1) then
  Me.Label1.Visible = False
  Me.Label2.Visible = False
Else
   Me.Label1.Visible = (Forms!YourFormName.opt_group1 = 1) 
   Me.Label2.Visible =  NOT (Forms!YourFormName.opt_group1 = 1) 
End IF

End Sub

Open in new window

0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38793369
I assume that the option group is bound to a field in the table that is the RecordSource for your report.

If that is the case, then you should be able to use the Report detail sections Format or Print event to execute code similar to:

me.label1.Visible = (me.[BoundField] = 1)
me.label2.Visible = (me.[BoundField] = 2)

or something along those lines.  Try the format event first.
0
 

Author Closing Comment

by:marian68
ID: 38793541
It worked very well.
Thank you and have a nice day.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38793585
too slow, again!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38793590
:-)
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question