Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Access - Continuous Form - Unbound Toggle

Posted on 2013-01-17
18
922 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
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.

 
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

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

Suggested Solutions

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

856 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