Solved

Check box Visible

Posted on 2014-01-17
7
256 Views
Last Modified: 2014-01-17
I have code for an "On Current" event of a form. It is working if the value = 1... it doesnt' know what to do if the value isn't. If the value isn't 1, I need the Me.chkBooked to be invisible. Any ideas?

Thanks!
0
Comment
Question by:cansevin
  • 3
  • 2
  • 2
7 Comments
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39788641
Try something like this:
Me.chkBooked.Visible = (YourValue =1)

Open in new window

0
 

Author Comment

by:cansevin
ID: 39788654
I forgot... the code I am using is below. I need to make it "invisible" if the value is not 1

Private Sub Form_Current()

Me.chkBooked.Visible = Me.Frame109.Value = 1

End Sub
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39788711
Judging by the name, you must be using an Option Group.  You need to also put your code in the AfterUpdate event of your Frame control.

Private Sub Frame109_AfterUpdate()
    Me.chkBooked.Visible = (Me.Frame109.Value = 1)
End Sub

Open in new window


In your OnCurrent event you could use the same code or better still just call the the other procedure, that way there's only one section that needs to be maintained rather than two.

Private Sub Form_Current()
    Call Frame109_AfterUpdate
End Sub

Open in new window


As an aside, I would rename Frame109 to something more appropriate.  Something like:
fraBookingSelection or grpBookingSelection maybe.
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:cansevin
ID: 39788749
Thanks for your help... Much appreciated. I added the "Call" to the Add current.

It is working when the value is 1. It just doesn't know what to do when the value is not 1 (which is to be invisible)

Is there an "Else" code to state that it should be invisible when the value is not 1?
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39788761
No it should work as this is written. There must be something else going on. Maybe you can upload a copy with just that form?
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 39788793
FWIW,

I generally avoid the syntax you are using because it does not explain what is happening.

I prefer code like these:

If Me.Frame109.Value = 1 Then
    Me.chkBooked.Visible=True
Else
    Me.chkBooked.Visible=False
End if

Or perhaps this:

If Me.Frame109.Value = 1 Then
    Me.chkBooked.Visible=False
Else
    Me.chkBooked.Visible=True
End if

...depending on your exact needs.
;-)

JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39789995
glad I could help...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

762 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