Toggle Box Back to normal?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a 100 toggle boxes on the form. I have it programmed that when you
select a box, it goes to a public sub that looks at whether there is a record
in a table, and either creates a record or changes it. This works fine, I
like it. However, if the record DOESN'T need to be changed- how do I tell the
code to make the toggle button back to a "0" position, not a "-1" position? A
text box on my form has the correct field name. sctn =
forms!frm_map!labelbox. In code, how do I tell it I want to reference
forms!frm_map! sctn? with sctn being the field name?
 
Change the Value property of the toggle button to 0 to raise the button back
to "non-depressed" state.
 
I know that Ken probably already helped you resolve the problem, but I'm
curious to know why you are using 100 toggle boxes in the first place, I know
you explained what they are doing, but I'm curious as to why. I know
curiousity killed the cat, but I can't help it, I'm naturally curious - if
you don't mind my asking, if not, then I understand completely.
 
I understand how to use the 0 and -1 states. What I need to know is how to
call, in a function that is being used for all the toggle buttons, for a
specific button to be turned back to 0.
Normally I'd write: forms!frm_map!C11 = 0
However, I don't want to hardcode the C11. I want that to generate from a
different field on the form. Something like- do I create a dim fldnm as
string and let it equal the "forms!frm_map!" & forms!frm_map!labelbox , but
that doesn't work. Help?
 
I am doing a map of the warehouse- the buttons fill in a table that prints
out the inventory in certain sections. I did not get an answer to my
question- so if you have any ideas I'd love to hear them.
Tammy
 
It's possible to carry a control object to a function and let the function
work on that control. I don't know how you'll be calling this function, but
in general, you can create a function that looks like this:

Public Function ChangeMyToggle(tglControlName As Control)
tglControlName.Value = 0
End Function

You'd call this function like this:

MyResult = ChangeMyToggle(Me.ToggleButtonName)

--

Ken Snell
<MS ACCESS MVP>
 
Maybe it's because I haven't been doing any programming/coding in awhile, but
I'm sorta confused as to exactly what you are after. Also, I tend to not
completely understand what a person is asking when they are being general -
which unfortantely is often the case in these types of forumns. From what I
am gather, you may be wanting to change the state of a toggle back from 0 to
-1 (or vice versa) depending on some other variable. You can do this by
having a function iterate through all the toggle buttons.

the psuedo-code would look something like

For each toggleButton on myForm
- Find the matching record in the db
- - if condition is met then change state
- - else do nothing

Are we on the same track? If so, let me know if you need help converting
the psuedo-code, or let me know if I'm off track as well.
 
Or, if the name of a toggle button is in a field or control (would be a bit
unusual, but there are times when this might be the situation), you could
use the contents of that control to get the control object:

MyResult =
ChangeMyToggle(Me.Controls(Me.NameOfTextBoxWithToggleButtonNameInIt.Value))
 
Back
Top