Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a Toggle Button on a Continuos Form

Status
Not open for further replies.

Accel45

Technical User
Jul 7, 2004
83
US
I have a continous Form "frmMemo"
I have a yes/no check box "WordsCk" on frmMemo.
I place a Toggle Button "Toggle23" bound to WordsCk.

I placed the code below in the AfterUpdate() of frmMemo
hoping that Toggle23 Caption would change depending on WordsCk in each record.

Private Sub Form_AfterUpdate()
If WordsCk = -1 Then
Toggle23.Caption = "Selected"
Else
Toggle23.Caption = "Cleared"
End If
End Sub

The problem is that all of the Toggle Captions for all Records change at the same time.
ie. they are all either "Selected" or "Cleared"
How can I make this work?

Accel45
 
Huh? Have you named all of your controls "Toggle23"?

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
It is a continuous form
Toggle23 is on each of the records in the continuous form
accel45

 
Hi Accel45,
I've experienced the same issue and after searching the archives here and not finding anything I chose to handle the issue in a different way. Any unbound control in the detail section of a continuous form will produce the same result. It either has the same name in each instance or is firing the same events or both. But, instead of using a toggle control try using just a button. Each instance of the button will operate uniquely (when pressed not all the buttons will press at the same time). I'm ASSUMING that you want to use a 'button' to accomplish this. You could just show the bound control as a checkbox and let the users click on that. However, when you press the button you will, at the same time, be able to identify which record you are working with in the continuous form. Retrieve that records unique key then with a select statement make the change to the table in code:

dim db as database
dim rs as recordset
dim strSQL as string

strSQL = "Select * from sometable where key = " & thekeyvalueretrievedfromtherecordyouareon"
set db = currentdb
set rs = db.openrecordset(strSQL)
if not rs.eof then
with rs
.edit
if !truefalsefield = true then
!truefalsefield = false
else
!truefalsefield = true
endif
.update
with end
form_formname.requery
end if

With the above you will be able to toggle the state of the boolean field. In order to display the change of the toggle I displayed the checkbox as read only so the button click would produce a discernable effect.

I did it this way for a totally different reason than what your explaining but the end result is the same. I had a select statement that included several joins. As a result I could not edit any record in the continuous form. Therefore, I did the above.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top