Results 1 to 5 of 5
  1. #1
    bo16tx is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2017
    Posts
    8

    Change Field Name from All Caps to Initial Cap

    Have a database that I'm cleaning up some poor field naming. While in the process, I want to change some all Cap names to initial Cap names, e.g., "COLOR" to "Color". Seems simple, however when I close the database and reopen, the All Caps names remain.

  2. #2
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Where are you changing it? Check that the field name in Table Design is Proper Case. Check that Control Names on the form are Proper Case. If either is not, correct them. Also, if you have DIM'med variables in the top of procedures that are all caps - correct them to Proper Case there.

    I refer to "Proper Case" as you noted "Color" as an example. Normally "Camel Case" is used - ItemNumber, DaysToShip, etc.

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Unfortunately Access treats upper and lower case names as the same.
    So once you have saved the table, it needs a bit of trickery.

    First try, renaming, saving then do a compact and repair.
    I doubt it will work but worth trying.

    Next, rename the fields e.g COLOR to ColorX. Save
    Then rename again to Color. Save again
    If my memory is correct, that should work

    BUT Color may be a reserved word in Access so it might be wise to rename anyway e.g. ProductColor
    If the field is already in use, temporarily turn on Name AutoCorrect before changing names.
    That will work with no further messing about.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    sWord = StrConv(sWord, 3)

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    This worked for me (single example) Acc 2010

    Code:
    CurrentDb.TableDefs("tblFatSeq").Fields("FatNo").Name = "FaTnO"
    Depending on how many tables/fields are involved, you could set up some looping and use propercase (as ranman suggested) for the strConv option.

    Had time to adjust: I had a table with all fields in Upper case-
    Code:
    '---------------------------------------------------------------------------------------
    ' Procedure : changeCaseOfTableFields
    ' Author    : mellon
    ' Date      : 24-Jan-2018
    ' Purpose   :To change the format of field names in a table
    'can be set up with a parameter if needed to do multiple tables
    '---------------------------------------------------------------------------------------
    '
    Sub changeCaseOfTableFields()
    
              Dim db As DAO.Database
              Dim tdf As DAO.TableDef
              Dim fld As DAO.Field
    10       On Error GoTo changeCaseOfTableFields_Error
    
    20        Set db = CurrentDb
    30        For Each tdf In db.TableDefs
    40            If tdf.name = "datarow" Then
    50                For Each fld In tdf.fields
    60                    Debug.Print "Initial name :" & fld.name
    70                    fld.name = StrConv(fld.name, 3)
    80                    Debug.Print "revised name : " & fld.name
    90                Next fld
    100           End If
    110       Next tdf
      
    changeCaseOfTableFields_Exit:
    120      Exit Sub
    
    changeCaseOfTableFields_Error:
    130      MsgBox "Error " & err.number & " in line " & Erl & " (" & err.Description & ") in procedure changeCaseOfTableFields of Module DataDictionary"
    140      Resume changeCaseOfTableFields_Exit
    End Sub
    Output:
    Initial name ELIVERY_HOUR
    revised name : Delivery_hour
    Initial name ELIVERY_INTERVAL
    revised name : Delivery_interval
    Initial name :STEM_PRICE_PER_MWH
    revised name : Stem_price_per_mwh
    Initial name :STEM_QUANTITY_MWH
    revised name : Stem_quantity_mwh
    Initial name :SUSPENSION
    revised name : Suspension
    Initial name :TOTAL_BID_QUANTITY
    revised name : Total_bid_quantity
    Initial name :TOTAL_OFFER_QUANTITY
    revised name : Total_offer_quantity
    Initial name :TRADE_DATE
    revised name : Trade_date


    Click image for larger version. 

Name:	ChangeFieldNameCase.png 
Views:	19 
Size:	11.2 KB 
ID:	32357

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 19
    Last Post: 07-12-2017, 01:15 PM
  2. Replies: 44
    Last Post: 04-26-2017, 01:53 PM
  3. Replies: 4
    Last Post: 01-27-2017, 04:59 PM
  4. Replies: 4
    Last Post: 12-14-2014, 01:41 PM
  5. How to Set Font to Small Caps using VBA
    By EddieN1 in forum Access
    Replies: 3
    Last Post: 04-11-2014, 05:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums