Solved

Access - Continuous Form - Unbound Toggle

Posted on 2013-01-17
18
898 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
 
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
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now