Solved

Access - Continuous Form - Unbound Toggle

Posted on 2013-01-17
18
908 Views
Last Modified: 2013-01-17
Hello All

I am working with a Continuous Form.  There is a Yes/No field in my table that is bound to the form but I hate how small the Checkbox visually is on my continuous form.

I know I can put a Toggle button on the form and set the Font to Wingdings 2 and if the toggle is checked change the Caption to "P" which will display a checkmark any size that I want.  However, since it is an unbound Toggle then whatever the last visual toggle I clicked ALL of the toggle controls display the same thing even if that particular record is No.

Is there any way in vbcode I can get around this for a continuous form OR does is there any way to make MS's checkbox control for a Y/N field bigger???????


The code I have for making the toggle display a check or not is:
Private Sub Pull_OnClick()
Private Sub tglPull_Click()
    If Me.LVLReportingMachPulledIndicator = True Then
        Me.LVLReportingMachPulledIndicator = False
        Me.tglPull.Caption = ""
       
    Else
        Me.LVLReportingMachPulledIndicator = True
        Me.tglPull.Caption = "P"
    End If
   
End Sub
0
Comment
Question by:wlwebb
  • 8
  • 4
  • 4
  • +1
18 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38788213
The Toggle button is a bound control, so bind it to your YesNo field.
0
 

Author Comment

by:wlwebb
ID: 38788266
fyed....
I am confused.....(which really doesn't take much to do ;-)))

This contradicts Mbiz's reply........  but I tried it anyway.  on the Toggle button I put its Control source as LVLReportingMachPulledIndicator.

However in the On_Click code for LVLReportingMachPulledIndicator I put the following If stmt.

I still get the same result..Either every Tgl is checked or they aren't just depends on what I clicked last.
Private Sub LVLReportingMachPulledIndicator_Click()
    If Me.LVLReportingMachPulledIndicator = True Then
    Me.tglPull.Caption = "P"
    Else
    Me.tglPull.Caption = ""
    End If
End Sub
0
 

Author Comment

by:wlwebb
ID: 38788301
well........there use to be a reply by Mbiz.........  Don't know where it went........
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 61

Expert Comment

by:mbizup
ID: 38788307
wlwebb,

I deleted it because it was inaccurate with regards to toggle buttons (apparently not soon enough) ...  I think fyed is on the right track here and can help you get sorted.
0
 

Author Comment

by:wlwebb
ID: 38788312
Mbiz...
Ok Thanks!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38788335
Another possibility that I havent tried out is to use a bound textbox instead of a button...

Set its properties to Locked and enabled.

In its click event, write code to toggle the text:


If "" & Me.Mytextbox = "" then
    Me.Mytextbox = "P"
Else
    Me.Mytextbox = ""
End if

Open in new window


And add conditional formatting to change the background color
0
 

Author Comment

by:wlwebb
ID: 38788338
Fyed

Ok, I am looking at my continuous form with that Toggle button bound to the Y/N field [LVLReportingMachPulledIndicator]

I have 5 records.  So when I click on the Y/N of any particular field the "Shading" of the one particular record turns off or on (Doesn't turn ALL of them Off/On)  Is there a way to get it to change the Caption instead of the Shading??????????
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38788344
-->> bound textbox instead

Bound to a text field.

So the values in this field will either be "P" representing 'checked' or "" representing 'Unchecked'.
0
 

Author Comment

by:wlwebb
ID: 38788356
Mbiz

The textbox doesn't like displaying wingdings 2........  Shows strange characters

I see...........  I changed the font to Calibiri and the textbox displays 0 or -1
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 38788427
Well, on the sample I built, binding the toggle to the Yes/No field works, but I get your point about the Visibility issue.

Although the button should be toggled, you are trying to change the caption to display the checkmark if it is true as well, could not get that to work.

But you could use a textbox to display the Checkbox.

1.  Set the control source of the textbox to: ="P"
2.  Set the special effect to raised
3.  set the font appropriately
4.  set then use conditional formatting to change the forecolor of the text between the background color and Black depending on the value of your yes no field.  I did it by creating two Expressions:

[YesNoField] = 0  => grey on grey
[YesNoField] = -1  => black on grey

6.  Set the TabStop property of the textbox to No
7.  Then use the GotFocus event of the textbox to change the value of your field and requery the textbox

Private Sub txtToggle_GotFocus

    me.SomeOtherControl.setfocus
    me.[YesNoField] = Not me.[YesNoField]
    me.txtToggle.Requery

End Sub
0
 

Author Closing Comment

by:wlwebb
ID: 38788535
WONDERFUL!!!!!

That Did the trick!!
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38788586
BTW, I used the GotFocus event of the textbox rather than the click event because I've never been very fond of the click event of a textbox.  I will occassionally use the double-click event but rarely the click event.

Glad I could help.

@Miriam: Got my points for the day (see experts thread),  the rest are all yours!   ;-)
0
 

Author Comment

by:wlwebb
ID: 38788632
WOW I LIKE THAT Fyed!   Only thing that looks quirky is when you hover over the textbox instead of a pointer like you normally have it displays a vertical bar like you're going to insert text.  I understand why since it's a textbox field but otherwise I like it..!!!!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38788634
Dale,

Lol!  We need to see more of experts like you out here, not less.  

People who post good, detailed answers like you do are too few and far between.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38788648
Thanks, Miriam.
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38788962
Only thing that looks quirky is when you hover over the textbox
Put a transparent button instead over the textbox.  (Set it's Transparent property to true).  Then your code would instead be on this button:
Private Sub btnToggle_Click()
    me.[YesNoField] = Not me.[YesNoField]
End Sub

Open in new window

You can also skip the Conditional Formatting step by using this expression in your textbox control instead:
= IIF([YesNoField],"P","")
0
 

Author Comment

by:wlwebb
ID: 38789284
Irog

Attempted that........  I brought the command button to the front and set Transparent to Yes
and its Backstyle to Transparent.

My code is
Private Sub cmdToggle_Click()
    Me.LVLReportingMachPulledIndicator = Not Me.LVLReportingMachPulledIndicator
End Sub

Nothing happens when I click....
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38790661
Here's a sample as I described.
DBtest.accdb
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

786 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