UCase and AfterUpdate Event

G

Gary

Hello,

This one strikes me as odd, so I thought I would drop a line to see if
anyone else has come across it?

I have a form with an underlying table that can be used to enter information
about computer systems. One of the fields is for the MAC Address. I want to
be able to convert the alpha parts to uppercase when the tab key goes to the
next field, so I wrote some code in the AfterUpdate event.

Private Sub MAC_Adress_AfterUpdate()

Me.MAC_Address.text = UCase(Me.MAC_Address.text)

The debugger flags it when I try to move to the next record with this error:

"Run time error '2115'
"The macro of function set to the BeforeUpdate or Validation Rule property
for this field is preventing Microsoft Access from saving data in the
field."

???

There are no BeforeUpdate events, nor are there any Validation Rules in
place. The field is a simple text field in the table. I ran this in VB with
text boxes and it worked fine.

I also tried to flag the text as a String variable, convert it to upper case
and return the String variable to the field, but that generates the same
error.

Thanks for any guidance.
Gary
 
F

fredg

Hello,

This one strikes me as odd, so I thought I would drop a line to see if
anyone else has come across it?

I have a form with an underlying table that can be used to enter information
about computer systems. One of the fields is for the MAC Address. I want to
be able to convert the alpha parts to uppercase when the tab key goes to the
next field, so I wrote some code in the AfterUpdate event.

Private Sub MAC_Adress_AfterUpdate()

Me.MAC_Address.text = UCase(Me.MAC_Address.text)

The debugger flags it when I try to move to the next record with this error:

"Run time error '2115'
"The macro of function set to the BeforeUpdate or Validation Rule property
for this field is preventing Microsoft Access from saving data in the
field."

???

There are no BeforeUpdate events, nor are there any Validation Rules in
place. The field is a simple text field in the table. I ran this in VB with
text boxes and it worked fine.

I also tried to flag the text as a String variable, convert it to upper case
and return the String variable to the field, but that generates the same
error.

Thanks for any guidance.
Gary

In Access you should reference the control's value property, not it's
Text property. Since the Value property is a control's default
property, you don't need to explicitly state it.

Private Sub MAC_Adress_AfterUpdate() '***
Me!MAC_Address = UCase(Me!MAC_Address) ' ***
End Sub

' *** Also, you have a mis-spelled either the field name or the event
name (Mac_Adress is not Mac_Address).

What happens if you correct those 2 items?
 
G

Gary

fredg said:
In Access you should reference the control's value property, not it's
Text property. Since the Value property is a control's default
property, you don't need to explicitly state it.

Private Sub MAC_Adress_AfterUpdate() '***
Me!MAC_Address = UCase(Me!MAC_Address) ' ***
End Sub

' *** Also, you have a mis-spelled either the field name or the event
name (Mac_Adress is not Mac_Address).

What happens if you correct those 2 items?

Ah, brilliant!! I am used to addressing it as in VB, that's probably why.
I retyped the subroutine in the message, that accounts for the misspell. It
was a typo on my part and not on the part of (or present that way) in the
code.

Thanks for the help, Fred!
-Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top