By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

toggle button caption on continuous form

n8kindt
100+
P: 221
i have a continuous form that i want a toggle button to display "on" or "off." everything i try changes every single caption on the continuous form--rather than the single row. here's what i have so far:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Paint()
  2. If OnOff.Value = True Then
  3. OnOff.Caption = "On"
  4. Else: OnOff.Caption = "Off"
  5. End If
  6. End Sub
it works, but every time the mouse moves over the button, the button flickers. this is not as clean as i would like it to be but if nothing else comes up, i suppose i can live with it.
Apr 10 '08 #1
Share this Question
Share on Google+
7 Replies


FishVal
Expert 2.5K+
P: 2,653
Hi, there.

The problem is that the buttons in different rows are just one single control. You could not change an appearance of the button in <all rows.
A workaround here may be bound ToggleButton control, which certainly requires additional field in the linked table to be bound to.

Regards,
Fish
Apr 10 '08 #2

n8kindt
100+
P: 221
Hi, there.

The problem is that the buttons in different rows are just one single control. You could not change an appearance of the button in <all rows.
A workaround here may be bound ToggleButton control, which certainly requires additional field in the linked table to be bound to.

Regards,
Fish
i'm sorry, i forgot to mention that it was indeed bound. i think i'm going to have to settle with the "flickering" for now. one small problem with this however, is when i delete a record i get runtime error 2424. "the expression you entered has a field, control, or property name that access cannot find." if i click end twice (since the error pops up twice), it works fine. so how do i bypass this error using the code i already have?
Apr 10 '08 #3

n8kindt
100+
P: 221
Expand|Select|Wrap|Line Numbers
  1. If DataErr = 2424 Then
  2.         Response = acDataErrContinue
  3. End If
i've got this much... where do i place the code??
Apr 10 '08 #4

n8kindt
100+
P: 221
Expand|Select|Wrap|Line Numbers
  1. If DataErr = 2424 Then
  2.         Response = acDataErrContinue
  3. End If
i've got this much... where do i place the code??

this is my final code. i realize i may not have been clear about my problem up above. the code i am listing below is the only solution i have to the problem of every single caption changing whenever one is changed in a continuous form. everything works great now except for a flicker whenever the mouse is moved over the button.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Paint()
  2.  
  3. On Error GoTo PROC_ERR
  4. If Not IsNull(Apply1.Value) Then
  5.     If OnOff.Value = True Then
  6.     OnOff.Caption = "On"
  7.     Me.Dirty = False
  8.     Else: OnOff.Caption = "Off"
  9.     End If
  10. Else: Exit Sub
  11. End If
  12. PROC_ERR:
  13.   On Error Resume Next
  14. End Sub
can anyone help with the flicker problem?
Apr 15 '08 #5

n8kindt
100+
P: 221
minor correction to the above code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Paint()
  2. On Error GoTo PROC_ERR
  3. If Not IsNull(OnOff.Value) Then
  4. If OnOff.Value = True Then
  5. OnOff.Caption = "On"
  6. Me.Dirty = False
  7. Else: OnOff.Caption = "Off"
  8. End If
  9. Else: Exit Sub
  10. End If
  11. PROC_ERR:
  12. On Error Resume Next
  13. End Sub
Apr 15 '08 #6

FishVal
Expert 2.5K+
P: 2,653
Hi, there.

You use Detail_Paint event which I could not find in Access 2003.
This makes me think you are using Access 2007.
If so, then you may take advantage of bound Image control to mimick toggle button.

In form RowSource:
Expand|Select|Wrap|Line Numbers
  1. SELECT ..., iif(OnOff, "X:\...\OnButtonFace.bmp", "X:\...\OffButtonFace.bmp") AS txtPathToButtonFace FROM ....
Image control is bound to [txtPathToButtonFace].

Image_Click event handler inverts [OnOff].Value.

Button faces may be grabbed directly from screen. ))

Unfortunately (or maybe fortunately :)) I have no Access 2007. If you does and want to give it a try, then code debugging is all upon you.

Regards,
Fish
Apr 16 '08 #7

n8kindt
100+
P: 221
Hi, there.

You use Detail_Paint event which I could not find in Access 2003.
This makes me think you are using Access 2007.
If so, then you may take advantage of bound Image control to mimick toggle button.

In form RowSource:
Expand|Select|Wrap|Line Numbers
  1. SELECT ..., iif(OnOff, "X:\...\OnButtonFace.bmp", "X:\...\OffButtonFace.bmp") AS txtPathToButtonFace FROM ....
Image control is bound to [txtPathToButtonFace].

Image_Click event handler inverts [OnOff].Value.

Button faces may be grabbed directly from screen. ))

Unfortunately (or maybe fortunately :)) I have no Access 2007. If you does and want to give it a try, then code debugging is all upon you.

Regards,
Fish
thanks for your advice. yes, i am running access 2007 so i will give your suggestion a go and post back with my results.
Apr 16 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.