CheckBox sets TextBox Msg

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
A CheckBox's bi-state sets a message in a TextBox to: "Edit Data" or "View Data" and sets a Public variable used to turn other controls on or off depending on CheckBox state.

The code below only go's as far as the first "If's" TextBox update and errors out, with: Run time error: 2115: The macro or function set to the BeforeUpdate or Validation Rule property for this field is preventing Access from saving the data in the field.

None of the affected controls have code or properties set for: BeforeUpdate or Validation. And, I am not working on a field or saving data?

Any ideas, see code below:

Private Sub Mode_CheckBox_Click()
'On Error GoTo Err_Mode_CheckBox_Click

If Value = True Then
ViewEdit = "E"
DoCmd.GoToControl "Mode_Box"
Me!Mode_Box.Text = "Edit Data"
Exit Sub
End If

If Value = False Then
ViewEdit = "V"
DoCmd.GoToControl "Mode_Box"
Me!Mode_Box.Text = "View Data"
Exit Sub
End If

Exit_Mode_CheckBox_Click:
Exit Sub

Err_Mode_CheckBox_Click:
MsgBox Err.Description
Resume Exit_Mode_CheckBox_Click
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
This problem has been fixed!

Changed the TextBox "Text" code to "Value" and set the "Validation Rule" to [<>"" or Is Null].

Private Sub Mode_CheckBox_Click()
On Error GoTo Err_Mode_CheckBox_Click

If Mode_CheckBox.Value = True Then
ViewEdit = "E"
DoCmd.GoToControl "Mode_Box"
Me!Mode_Box.Value = "Edit Data Mode"
Me!Mode_Box.BackColor = 15395063
DoCmd.GoToControl "ListBox_Lookup"
Exit Sub
End If

If Mode_CheckBox.Value = False Then
ViewEdit = "V"
DoCmd.GoToControl "Mode_Box"
Me!Mode_Box.Value = "View Data Mode"
Me!Mode_Box.BackColor = 15200998
DoCmd.GoToControl "ListBox_Lookup"
Exit Sub
End If

Exit_Mode_CheckBox_Click:
Exit Sub

Err_Mode_CheckBox_Click:
MsgBox Err.Description
Resume Exit_Mode_CheckBox_Click
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,704
Messages
6,161,390
Members
451,701
Latest member
ckrings

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top