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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toggle Button 1

Status
Not open for further replies.

tnago

Technical User
May 21, 2003
23
CA
I am trying to use a toggle button on a form to update the value of a record in the database. I want to have a button whose default state is Open and when toggled status change to Close and the corresponding record in the database is updated. Any help will be greatly appreciated.

 
are you using a form? If so, when you enter data, it is updated.

Rollie E
 
Hi Rollie

Maybe I was not able to explain my question properly. I have also searched this site for anything similar to my problem but didn't find anything. Ok, Let me try it again. I have a field 'Closed' in my database which indicates wheather an incident is open or closed. On my form I have a toggle button which I want to use to change the status of this field 'Open' to 'Close' or vise versa. I was looking for some help to acheive this. I understand it can be done only through code rather then manipulating any options through properties.
 
I gather that the recordset is bound to a form. That is the properties of the form show a recordset source. Is that true. Then in the records bound to the recordset there is a field named something. That field is open or closed. How do you indicate an open and a close. If for instance you used a textbox and for an open you said open in that textbox (which represents a field in recordset) you put an "Open" or "closed."

Then your button would have behind it some code like this.

sub command0_click()

if me.Splfield = "Yes" then
me.Splfield = "No"
else
me.Splfield = "Yes"
endif

This would click between "Yes" and "no."


rollie@bwsys.net
 
Hi Rolliee

Thanks for your suggestion. I am currently trying to use the following event procedure on click.
------------------------------------------------
Private Sub Toggle141_Click()
If Me.Toggle141 = -1
Me.Toggle141.Caption = "CLOSE"
Else
Me.Toggle141.Caption = "OPEN"
End If
End Sub
---------------------------------------------------
However I am having problem that when I go to the next record it does not change caption to indicate wheather it "OPEN" or "CLOSE" though it does change from normal to pressed. I am not using an textbox to indicate any change. All is suppose to be done by the toggle button. So if the incident is close then it will be pressed in and will show caption of CLOSE and otherwise it will be normal and display caption of OPEN.
 
If you wish some action to occur on all records, you should to the test and make the actions a part of the "OnCurrent" event not a subroutine that does not get fired.

Rollie
 
Hi Rollie

Thanks for the help on this issue. On Current does solve the issue of indicating if the record is open or close. Also by adding on Click for toggle it changes the open to close and vise versa.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top