Hi fellows
Just a quick question about my database. I have one table in my database which i import it from some other Access db. This table has many fields, such as Initials, Medication name etc....but they are all in different upper case and lower case? Is there a way in Access or VB code so we could change all the current data (in the fields) same Lower case or upper case.
I have this under text box control, and its working fine, but this will effect only on or for new entry on the form. It doesnt effect on the current data in the fields. -
-
Private Sub Initials_AfterUpdate()
-
-
If IsNull(Screen.ActiveControl) = False Then
-
-
Screen.ActiveControl = StrConv(Screen.ActiveControl, vbUpperCase)
-
-
End If
-
End Sub
-
any Idea?
Thanks again
15 11519
You can do the same thing to data already existing by using the same function in an UpDate query.
Linq ;0)>
You can do the same thing to data already existing by using the same function in an UpDate query.
Linq ;0)>
I am not sure how to do that.
I am not sure how to do that.
I got that thing to work, now my field is in all upper case -
-
UPDATE TABLENAME SET FIELDNAME = UCASE([FIELDNAME]);
-
-
but what If u want to convert something like that.
Linezolid instead of LINEZOLID
Thx.
- strconv(YourFieldName,vbProperCase)
will capitalize the first letter of each word in a field. - strconv(left(YourFieldName,1),vbUpperCase)& right(YourFieldName,len(YourFieldName)-1)
will capitalize only the first letter of the first word in the field.
Linq ;0)>
Hi fellows
Just a quick question about my database. I have one table in my database which i import it from some other Access db. This table has many fields, such as Initials, Medication name etc....but they are all in different upper case and lower case? Is there a way in Access or VB code so we could change all the current data (in the fields) same Lower case or upper case.
I have this under text box control, and its working fine, but this will effect only on or for new entry on the form. It doesnt effect on the current data in the fields. -
-
Private Sub Initials_AfterUpdate()
-
-
If IsNull(Screen.ActiveControl) = False Then
-
-
Screen.ActiveControl = StrConv(Screen.ActiveControl, vbUpperCase)
-
-
End If
-
End Sub
-
any Idea?
Thanks again
Here is one for you to consider it acts on the ON KEYPRSS event of the control so in other words it forces characters to upper case as you type them for your any new records you might put in there - On Error GoTo Err_Surname_KeyPress
-
Dim Character
-
Character = Chr(KeyAscii)
-
KeyAscii = Asc(UCase(Character))
-
-
Exit_Surname_KeyPress:
-
Exit Sub
-
-
Err_Surname_KeyPress:
-
MsgBox err.Description, vbInformation, "Surname KeyPress Command Cancelled"
-
Resume Exit_Surname_KeyPress
Regards
Jim
- strconv(YourField,vbProperCase)
will capitalize the first letter of each word in a field. - strconv(left(YourField,1),vbUpperCase)& right(YourField,len(YourField)-1)
will capitalize only the first letter of the first word in the field.
Linq ;0)>
Thank you for posting, but this will take care of new entry into the field. How would I do it for exsisting record in the table?
Thank you for posting, but this will take care of new entry into the field. How would I do it for exsisting record in the table?
run an UPDATE query... this is some sample SQL that you can paste into the query SQL window and run as is provided you have a table of the same name and field of the same name and some data to work with - UPDATE tblcustomerinformation SET tblcustomerinformation.Lastname = UCase([LastName]);
Regards
Jim
run an UPDATE query... this is some sample SQL that you can paste into the query SQL window and run as is provided you have a table of the same name and field of the same name and some data to work with - UPDATE tblcustomerinformation SET tblcustomerinformation.Lastname = UCase([LastName]);
Regards
Jim
I have this already, and all the record are in Ucase. but I want to run a query where I want my data is to be in this format.
"Some Name" currently I have all the information in Ucase.
I have this already, and all the record are in Ucase. but I want to run a query where I want my data is to be in this format.
"Some Name" currently I have all the information in Ucase.
Are you saying the first letter of EACH word in the same field should be capilized for all of your existing data please clarify
Are you saying the first letter of EACH word in the same field should be capilized for all of your existing data please clarify
yes u got it right.
Thx alot
yes u got it right.
Thx alot
This will capitalize the first letter of each word. Paste it into a module and save the module whatever you like bas_strings something like that. It is a Function that you can call from your query qrid like this
Capitalize([TheNameOfYourField])
The above line if entered into 'Update To' row of an UPDATE query in the grid will update your data . Remember nothing is perfect..what sequence of characters constitute a word as we know it? beware of anomolies
If you want to see the results before you update (ie: you are not sure) then use it as an extra column in a SELECT query by typing into the Fields row in the grid this:
MyCheck: Capitalize([TheNameOfYourField])
and then run the query as a SELECT query you will then see the differences side by side in datasheet - Public Function Capitalize(str)
-
'This function capitalizes each of the words in a sentence.
-
Dim i
-
Dim t
-
t = LCase(CStr(str))
-
If t <> "" And Not IsNull(t) Then
-
t = UCase(Mid(t, 1, 1)) & Mid(t, i + 2)
-
For i = 1 To Len(t) - 1
-
If Mid(t, i, 1) = "." Then
-
' Capitalize words/letters preceded by "."
-
t = Left(t, i) & UCase(Mid(t, i + 1, 1)) & Mid(t, i + 2)
-
End If
-
If Mid(t, i, 2) = Chr(13) + Chr(10) Then
-
' Capitalize words preceded by carriage return plus
-
' linefeed combination.
-
t = Left(t, i) & UCase(Mid(t, i + 2, 1)) & Mid(t, i + 3)
-
End If
-
If Mid(t, i, 1) = " " Then
-
' Capitalize words preceded by a space:
-
t = Left(t, i) & UCase(Mid(t, i + 1, 1)) & Mid(t, i + 2)
-
End If
-
Next
-
End If
-
Capitalize = t
-
End Function
yes u got it right.
Thx alot
There's been a lot of great work on this thread....but I have to ask. Why do you care what your data in your tables looks like Caps Wise? Access stores data for the sake of content, not looks. That's what forms and reports are for. And you have total control on what the data looks like using the format option. I have to wonder about justifying the time it takes to do this, when in reality, it doesn't matter. Just my .02
J
Using the native Access function - strconv(YourFieldName,vbProperCase)
as stated in Post # 5 above, you can replace the 25 line custom function of Post # 12 with - Public Function Convert2ProperCase(YourField As String) As String
-
Convert2ProperCase = StrConv(YourField, vbProperCase)
-
End Function
In your query you would then use - Convert2ProperCase([YourFieldName])
Or by simply replacing vbUpperCase with its numeric equivalent of 3 (you can't use the VB constant vbUpperCase in a query) you could simply use - StrConv([YourFieldName],3)
Both will capitalize the first letter of each word in the field, which is the OP’s objective.
Linq ;0)>
Vis a vis Jconsulting's comments, I think it comes down to would you like to do the formatting once, at the source (read Table) or do it everytime you use the field? If the field appears in 3 forms and 3 reports, you'd have to format it 6 times!
Linq ;0)>
Vis a vis Jconsulting's comments, I think it comes down to would you like to do the formatting once, at the source (read Table) or do it everytime you use the field? If the field appears in 3 forms and 3 reports, you'd have to format it 6 times!
Linq ;0)>
>>Linq and All,
That's a good point, and I concede that the option to format text should be controlled once, but through a function that can be re-used. So whether you're entering data directly, or using an update query or import spec, or outputting to a report or displaying in a form, the proper fields can be "filtered" as you go, so there's no after-the-fact cleanup. Taking that into account, the functions included in this thread are well written extremely useful for that purpose. I have added them to my Library! :o)
J
Sign in to post your reply or Sign up for a free account.
Similar topics
by: semovrs |
last post by:
Hello, everyone!
I would appreciate any input or advice on the following quite simple
issue:
If I search through a file list using grep -E '.*$' it will
not pull files ending in JPG and files...
|
by: David |
last post by:
What can I do to accept either uppercase or lower case " y or n" in the
program below.?
any help will be appreciated
#include <iostream>
using namespace std;
//class definigtion
class Pizza...
|
by: DJ |
last post by:
Can someone tell me the library call that converts strings to lower case or
retrns a new string that is lower case of the original, thanks
im using <string>
David
|
by: Janice |
last post by:
char* line = "abcd";
How to convert the line to upper case and print?
Any option for printf to do this?
Thanx
|
by: Chris |
last post by:
Hi,
How can I programatically set Upper, Lower and Normal case on a label or text box controls?
Thanks
|
by: Eric Lindsay |
last post by:
Should HTML 4.01 Strict markup be done in upper case or in lower case?
I understand that HTML allows either upper or lower case. I also notice
that XHTML apparently requires lower case. However I...
|
by: B Williams |
last post by:
I have written some code that will take in a string and print out the
reverse, but I also want it to check for upper and lower case and swap them.
Will someone assist me?
include <iostream>...
|
by: silversnake |
last post by:
Hi , dose one know the code for checking through a string for upper or lower case
char's and reverse them of find ?
thanks
|
by: cfmx2008 |
last post by:
Hi Guys,
I hope you could help me to solve this problem. Here it is: I have a huge table of data. Some data are Lower case and some are upper case. these data could be changed by agents, But I want...
|
by: vhsb69 |
last post by:
WeIrd - my I,O and P keys tyPe Out In uPPercase, everythIng else Is In lOwercase.
Keys are nOt stIckIng. Any One gOt any Ideas?
Please helP me I am very cOnfused.
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |