Radioactiveduck
New member
- Local time
- Today, 14:19
- Joined
- Sep 9, 2009
- Messages
- 9
I have a form with the following fields and data types:
Date: text in "mmm dd, yyyy" format
JAF: checkbox
EFS: checkbox
txt_ChAttn: textbox, generic format
Note: textbox, generic format
Basically, I've written code that does an AfterUpdate whenever JAF or EFS are checked or unchecked. It writes "John Doe" or "Jane Doe" into the txt_ChAttn textbox depending on which one is checked. I get the following vba error whenever it runs, however:
Run-time error '2115':
the macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Office Access from saving the data in the field.
Now, I checked the results, and it actually is updating the txt_ChAttn textbox correctly, but it still throws this error every time you check or uncheck the checkboxes. Here is the code for the updates:
Private Sub EFS_AfterUpdate()
If EFS = -1 Then
If JAF = -1 Then
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = "John Doe, Jane Doe"
Me.Refresh
Else
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = "John Doe"
Me.Refresh
End If
Else
If JAF = -1 Then
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = "Jane Doe"
Me.Refresh
Else
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = ""
Me.Refresh
End If
End If
End Sub
Private Sub JAF_AfterUpdate()
If EFS = -1 Then
If JAF = -1 Then
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = "John Doe, Jane Doe"
Me.Refresh
Else
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = "John Doe"
Me.Refresh
End If
Else
If JAF = -1 Then
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = "Jane Doe"
Me.Refresh
Else
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = ""
Me.Refresh
End If
End If
End Sub
Depending on which conditions are met, it always highlights the
"Me.txt_ChAttn.Text =" line, regardless of which combination of checked/unchecked the textboxes fall under. Any ideas on what's causing this error, and how I can get rid of it? As I said, it is updating the textbox correctly.
EDIT: I can't seem to force it to post the code with the correct text spacing, so it may look a bit sloppy.
Date: text in "mmm dd, yyyy" format
JAF: checkbox
EFS: checkbox
txt_ChAttn: textbox, generic format
Note: textbox, generic format
Basically, I've written code that does an AfterUpdate whenever JAF or EFS are checked or unchecked. It writes "John Doe" or "Jane Doe" into the txt_ChAttn textbox depending on which one is checked. I get the following vba error whenever it runs, however:
Run-time error '2115':
the macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Office Access from saving the data in the field.
Now, I checked the results, and it actually is updating the txt_ChAttn textbox correctly, but it still throws this error every time you check or uncheck the checkboxes. Here is the code for the updates:
Private Sub EFS_AfterUpdate()
If EFS = -1 Then
If JAF = -1 Then
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = "John Doe, Jane Doe"
Me.Refresh
Else
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = "John Doe"
Me.Refresh
End If
Else
If JAF = -1 Then
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = "Jane Doe"
Me.Refresh
Else
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = ""
Me.Refresh
End If
End If
End Sub
Private Sub JAF_AfterUpdate()
If EFS = -1 Then
If JAF = -1 Then
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = "John Doe, Jane Doe"
Me.Refresh
Else
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = "John Doe"
Me.Refresh
End If
Else
If JAF = -1 Then
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = "Jane Doe"
Me.Refresh
Else
Me.txt_ChAttn.SetFocus
Me.txt_ChAttn.Text = ""
Me.Refresh
End If
End If
End Sub
Depending on which conditions are met, it always highlights the
"Me.txt_ChAttn.Text =" line, regardless of which combination of checked/unchecked the textboxes fall under. Any ideas on what's causing this error, and how I can get rid of it? As I said, it is updating the textbox correctly.
EDIT: I can't seem to force it to post the code with the correct text spacing, so it may look a bit sloppy.
Last edited: