Results 1 to 10 of 10
  1. #1
    LeadTechIG is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2014
    Posts
    23

    How Do I Change Data Type


    Hello all,

    After years of working in my databases, I noticed that the programmer that originally built them designed the Data Type for the fields designated for "currency" as "text" instead. When I tried to change the data type, I got an error that reads "Microsoft Office Access can't change the data type. There isn't enough disk space or memory."

    How do I get around this stumbling block? I would like greatly to change those data types to "currency".

    Any help would be much appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Could try creating a new field in the table, number or currency type (I would use number). Run an UPDATE query to populate the new field with data from the old field. Delete old field. Rename new field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    LeadTechIG is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2014
    Posts
    23
    Thank you for your response.

    I have attempted this since receiving your idea, and it isn't working - however, I'm quite confident that the problem could be user error on my end.

    I created an update query with:

    Field: OldField
    Table: CorrectTable
    Update To: NewField
    Criteria: [Blank]
    of: [Blank]

    When I click "RUN" nothing happens. Do you have any suggestions?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Post the exact SQL statement of the UPDATE action query. I think you have the fields backwards.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    LeadTechIG is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2014
    Posts
    23
    How does this look?

    UPDATE [ASSET DATABASE] SET [ASSET DATABASE].[NEW FEE] = "OLD FEE";

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Try:

    UPDATE [ASSET DATABASE] SET [NEW FEE] = Val([OLD FEE]);
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    LeadTechIG is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2014
    Posts
    23
    Thank you. Your suggestions moved me in the right direction. However, the NEW FEE field is populated by "$0.00" instead of the values in the OLD FEE field.

  8. #8
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    how is the [old fee] value actually stored does it appear as a currency string $5.00 for 5 dollars? if so you may need to strip the $ mark before using the VAL function

    here's an example:

    testcurrency VALconversion
    $5.00 0
    $ 10.00 0
    10 10
    A10 0


    notice the only one that got converted correctly was the one with nothing but a valid numeric value.

    if your data is consistently in the $XX.XX format where there is no space and no other alpha characters in the data you could still use a modified version of june's suggestion:

    val(right([old fee], len([old fee]) - 1))

    you would then get this result for the same data set:

    testcurrency VALconversion
    $5.00 5
    $ 10.00 10
    10 0
    A10 10

    Notice it captures everything EXCEPT the straight number so a further modification:

    IIf(IsNumeric([testcurrency]),CCur([testcurrency]),Val(Right([testcurrency],Len([testcurrency])-1)))

    yields this:

    testcurrency VALConversion
    $5.00 $5.00
    $ 10.00 $10.00
    10 $10.00
    A10 $10.00

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Thanks, rpeare, I completely overlooked that currency symbol and possibly other characters and/or space would probably be part of the original data. Consistency of structure is critical when manipulating strings. If there can be other configurations (such as multiple alpha/symbol characters as prefix), gets more complicated.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    LeadTechIG is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2014
    Posts
    23
    Thank you very much! The two of you have given me the information I need to fix what I need to fix. Your help is much appreciated!

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

Similar Threads

  1. While Importing Change in data type
    By drunkenneo in forum Import/Export Data
    Replies: 1
    Last Post: 09-01-2014, 06:49 AM
  2. change data type for multiple fields
    By axg275 in forum Access
    Replies: 1
    Last Post: 03-11-2014, 09:31 AM
  3. Change Percentage Data Type
    By jo8701 in forum Access
    Replies: 1
    Last Post: 02-08-2012, 07:15 AM
  4. Replies: 1
    Last Post: 02-22-2011, 11:14 AM
  5. change data type in make table query
    By jgelpi16 in forum Queries
    Replies: 2
    Last Post: 01-26-2011, 09:37 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