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

How to solve the "runtime error 2115"

P: 1
Hi, I have a database-form with a couple of text boxes in it.
I want to replace the first letter that is written in a
text box with an uppercase letter, so I use the "after update" event and have written the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub straatenhuisnummer_AfterUpdate()
  2. dim anaam as string
  3. anaam = Forms!medewerker!straatenhuisnummer.Text
  4. anaam = UCase(Left(anaam, 1))
  5. Forms!medewerker!straatenhuisnummer.Text = anaam
  6. End Sub
When the code is performed, I get the following
error, which states "the macro or function set to the beforeupdate or validationrule property for this field is preventing Microsoft Access from saving the data in this field".
Can anyone help me with this? thanks!
Mar 8 '12 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 31,494
You are updating the control in the control's own AfterUpdate event procedure. That doesn't make much sense does it ;-)

Try using BeforeUpdate instead :
Expand|Select|Wrap|Line Numbers
  1. Private Sub straatenhuisnummer_BeforeUpdate(Cancel As ...)
  2.     With Me
  3.         .straatenhuisnummer = Mixcase(.straatenhuisnummer)
  4.     End With
  5. End Sub
Also, please don't post code you've typed in directly in future. It wastes our time and isn't greatly appreciated. See Before Posting (VBA or SQL) Code.
Mar 8 '12 #2

Post your reply

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