Hi.
BeforeUpdate code:
Me!cboFoo.Text = UCase(Me!cboFoo.Text)
I get the error:
Run-time error '2115':
The macro or function set to the BeforeUpdate or ValidationRule
property for this field is preventing Microsoft Access from saving
the data in the field.
Why is that?
--
Georges 10 4668
I'm not sure why, but Access won't let you change a control's contents during
BeforeUpdate. My work-around has always been to do this sort of thin in the
AfterUpdate handler. You won't be able to use the .Text property there, so
just use the value, and check for Null. By the way, since you're describing a
combo box here, the value should automatically be converted to the same case
as the matching selection with no code whatsoever.
Anyway, if it were a text box, this is an exaple of how I would do it...
Private Sub txtFoo_AfterUpdate()
If IsNull(Me!txtFoo) Then Exit Sub
Me!txtFoo = UCase(Me!txtFoo)
End Sub
On Wed, 10 Dec 2003 01:41:05 +0100, Georges Heinesch <ne**@geohei.lu> wrote: Hi.
BeforeUpdate code: Me!cboFoo.Text = UCase(Me!cboFoo.Text)
I get the error:
Run-time error '2115':
The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Access from saving the data in the field.
Why is that?
Steve Jorgensen wrote: I'm not sure why, but Access won't let you change a control's contents during BeforeUpdate. My work-around has always been to do this sort of thin in the AfterUpdate handler. You won't be able to use the .Text property there, so just use the value, and check for Null.
This works, but ... (see below)
By the way, since you're describing a combo box here, the value should automatically be converted to the same case as the matching selection with no code whatsoever.
In case the "Auto Expand" is set to Yes. But in one of my controls it's not.
Anyway, if it were a text box, this is an exaple of how I would do it...
Private Sub txtFoo_AfterUpdate() If IsNull(Me!txtFoo) Then Exit Sub Me!txtFoo = UCase(Me!txtFoo) End Sub
Yep, working. Preferntially, I would like to have the entered letters be
converted already upon input from lowercase to uppercase. I.o.w., all
entered letters (also lowercase) should show up as uppercase. I tried it
with a mask (>aaaa). To my great surprise, I saw that with "Auto Expand"
of a ComboBox set to Yes, the text completes to the end when entering
the first letter.
I explain:
ComboBox options:
ABCD
EFGH
IJKL
Without the mask:
A ABCD (BCD inverted)
The second entered letter goes after the A
With the mask:
A ABCD
The entire 4 letters "ABCD" are already completed
The latter behaviour is not required. How can I use a mask and make
Access behave like for the first situation (without a mask)?
TIA
--
Georges
Georges, Yep, working. Preferntially, I would like to have the entered letters be converted already upon input from lowercase to uppercase. I.o.w., all entered letters (also lowercase) should show up as uppercase. I tried it with a mask (>aaaa). To my great surprise, I saw that with "Auto Expand" of a ComboBox set to Yes, the text completes to the end when entering the first letter.
Use the Change-event to convert to UpperCase upon input.:
Me!cboName.text=UCase(Me!cboName.text)
--
Hope this helps
Arno R
On Wed, 10 Dec 2003 08:49:33 +0100, "Arno R" <ar****************@tiscali.nl>
wrote: Georges,
Yep, working. Preferntially, I would like to have the entered letters be converted already upon input from lowercase to uppercase. I.o.w., all entered letters (also lowercase) should show up as uppercase. I tried it with a mask (>aaaa). To my great surprise, I saw that with "Auto Expand" of a ComboBox set to Yes, the text completes to the end when entering the first letter.
Use the Change-event to convert to UpperCase upon input.: Me!cboName.text=UCase(Me!cboName.text)
There's a problem with the Change event, and changing the .Text property.
When you set the Text property, Access insists on trying to update the Value
immediately as if you had tabbed out of the field, and the data may not yet be
valid after any given keypress. Instead, I would use the OnKeypress event,
and change the Ascii code of any lower case letter to an upper case one.
Steve, There's a problem with the Change event, and changing the .Text property. When you set the Text property, Access insists on trying to update the Value
I was not aware of that. Thanks.
Never ran into this problem because where I used it, there is no validation needed for the input.
It explains the 'kind of screen-flickering' though.
Arno R
Arno R wrote: Use the Change-event to convert to UpperCase upon input.: Me!cboName.text=UCase(Me!cboName.text)
The .Text property does a great deal more than just chaning the content
of a control (not the field). It triggers some events (e.g.
BeforeUpdate, ...) without this being desired.
--
Georges
Steve Jorgensen wrote: Use the Change-event to convert to UpperCase upon input.: Me!cboName.text=UCase(Me!cboName.text)
There's a problem with the Change event, and changing the .Text property. When you set the Text property, Access insists on trying to update the Value immediately as if you had tabbed out of the field, and the data may not yet be valid after any given keypress. Instead, I would use the OnKeypress event, and change the Ascii code of any lower case letter to an upper case one.
Which mothod would you then use inside the OnKeyPress event to change
the control's content using VBA? The .Text or .Value or ... property?
I discovered that the very trivial task of changing the content of a
control is not trivial at all. There are 2 possibilities.
1. .Text property. This triggers some events right after the .Text
property is executed.
2. .Value property. This doesn't trigger any events, also not the usual
events (e.g. BeforeUpdate, ...) when leaving the control. This is not
desired either.
Simply changing the content of a control without influencing the trigger
behaviour of events doesn't seem to be possible.
--
Georges
On Wed, 10 Dec 2003 11:20:47 +0100, Georges Heinesch <ne**@geohei.lu> wrote: Steve Jorgensen wrote:
Use the Change-event to convert to UpperCase upon input.: Me!cboName.text=UCase(Me!cboName.text)
There's a problem with the Change event, and changing the .Text property. When you set the Text property, Access insists on trying to update the Value immediately as if you had tabbed out of the field, and the data may not yet be valid after any given keypress. Instead, I would use the OnKeypress event, and change the Ascii code of any lower case letter to an upper case one.
Which mothod would you then use inside the OnKeyPress event to change the control's content using VBA? The .Text or .Value or ... property?
None of the above. Change the value of KeyAscii instead, so it's as if the
upper case letter was typed instead of the lower case letter.
Private Sub txtFoo_KeyPress(KeyAscii As Integer)
If KeyAscii >= 32 Then
Debug.Print KeyAscii;
KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
Debug.Print " " & KeyAscii
End If
End Sub
Steve Jorgensen wrote: None of the above. Change the value of KeyAscii instead, so it's as if the upper case letter was typed instead of the lower case letter.
Private Sub txtFoo_KeyPress(KeyAscii As Integer) If KeyAscii >= 32 Then Debug.Print KeyAscii; KeyAscii = Asc(UCase$(Chr$(KeyAscii))) Debug.Print " " & KeyAscii End If End Sub
Works great!
I changed it slightly into ...
Private Sub txtFoo_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
Why did you include the >= 32 condition?
--
Georges
On Wed, 10 Dec 2003 15:45:27 +0100, Georges Heinesch <ne**@geohei.lu> wrote: Steve Jorgensen wrote:
None of the above. Change the value of KeyAscii instead, so it's as if the upper case letter was typed instead of the lower case letter.
Private Sub txtFoo_KeyPress(KeyAscii As Integer) If KeyAscii >= 32 Then Debug.Print KeyAscii; KeyAscii = Asc(UCase$(Chr$(KeyAscii))) Debug.Print " " & KeyAscii End If End Sub
Works great! I changed it slightly into ...
Private Sub txtFoo_KeyPress(KeyAscii As Integer) KeyAscii = Asc(UCase(Chr(KeyAscii))) End Sub
Why did you include the >= 32 condition?
Codes less than 32 are non-printing control characters such as Enter or Tab.
I wasn't sure how all the string functions would handle them, so I thought it
safer to skip processing of them. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jack |
last post by:
Hi,
I am trying to test a sql statement in Access which gives me
the error as stated in the heading.
The sql statement is built as a part of asp login verification,
where the userid and password...
|
by: Neil Ginsberg |
last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC
linked tables. I recently created a new set of tables for the app, and users
are complaining that unsaved data is being...
|
by: Sam White |
last post by:
I have set up a MySQL db on one server, IIS 6.0 on another. Using
Frontpage I created some forms to input data. On a test page I made, I
have 4 fields. First is the ID which is autonumber (I leave...
|
by: John |
last post by:
My data has 10 accounts.
Two forms are opened simultaneously. Form1 is unbound and displays three
records:
Account Quantity
101 17
104 25
107 ...
|
by: Neil Ginsberg |
last post by:
I'm having some problems with an Access 2000 MDB file with a SQL Server 7
back end, using ODBC linked tables. I previously wrote about this, but am
reposting it with some additional information and...
|
by: jpr |
last post by:
Hello,
I know that this is not the rule but need some help. My datbase has
three tables:
MASTER
TEMPLATES
FORMS
I have a form which is based on a table named MASTER.
I have a primary key...
|
by: Mark |
last post by:
I have a VB 6 program that I have saved an audio file to using DAO and the
appendchunk as is shown at http://support.microsoft.com/kb/103257/EN-US/. ; I
have it working fine in that app (it saves...
|
by: Timothy.Rybak |
last post by:
Hello all,
This is my first attempt at an application, so kid gloves are
appreciated.
I need to make a very simple form that only has a few elements. One is
TraceCode - a text field that is...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |