Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access - Continuous Form - Unbound Toggle

Posted on 2013-01-17
18
Medium Priority
?
980 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
[X]
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
  • 8
  • 4
  • 4
  • +1
18 Comments
 
LVL 48

Expert Comment

by:Dale Fye
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 48

Accepted Solution

by:
Dale Fye earned 2000 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 48

Expert Comment

by:Dale Fye
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 48

Expert Comment

by:Dale Fye
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

618 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