Results 1 to 3 of 3
  1. #1
    accote is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    35

    Convert Text to Number in Multivalue Table Field without data loss

    Hi



    Big problem here, I have a multivalue text field called "Groups" that is generated through a relationship
    with another table called "Comments". When I set this up I left the field as a text field when it should
    have been a number field, and now I can't use the database with sharepoint, because the field needs
    to be a number field.
    My Question is there a way to convert it without loosing all my data, as there are over 5000 records?
    My Table with the multivalue field is called "Contacts", the field is called "Groups".

    I tried update and append queries but I must be doing something wrong, so detailed explanation would
    be very much appreciated.

    Thank You

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,953
    I just tested changing a multi-value text field to number type and no data was lost. Make copy of your table and test. The related field in Comments will also have to be number type.
    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
    accote is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    35
    Got it resolved, thought I share if someone else has the same dilemma.
    Created another MVF called Groups1 and set it as a Number field then ran the following VB Function.

    Public Function UpdatMVFField()
    On Error GoTo err_proc
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Dim strSQL As String
    Dim strSQL2 As String

    strSQL = "SELECT ID, CommentID " & _
    "FROM Contacts INNER JOIN Comments ON Contacts.Groups.Value = Comments.Comment " & _
    "WHERE (((Comments.CommentID) Is Not Null)) " & _
    "ORDER BY Contacts.ID;"

    Set dbs = CurrentDb
    With dbs
    Set rst = .OpenRecordset(strSQL, , dbReadOnly)
    While rst.EOF = False
    strSQL2 = "INSERT INTO Contacts ( Groups1.[Value] ) " & _
    "VALUES ( " & rst!CommentID & " ) " & _
    "WHERE (((Contacts.ID)=" & rst!ID & "));"
    .Execute strSQL2, dbFailOnError
    rst.MoveNext
    Wend
    End With


    exit_proc:
    On Error Resume Next
    rst.Close
    Set rst = Nothing
    dbs.Close
    Set dbs = Nothing
    Exit Function

    err_proc:
    MsgBox Err.Description
    Resume exit_proc

    End Function

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

Similar Threads

  1. Convert number to text
    By Bertrand82 in forum Queries
    Replies: 7
    Last Post: 10-12-2012, 01:19 PM
  2. Replies: 5
    Last Post: 06-19-2012, 10:46 AM
  3. Convert Text to Number
    By Jerseynjphillypa in forum Import/Export Data
    Replies: 7
    Last Post: 05-09-2012, 12:45 PM
  4. Replies: 1
    Last Post: 08-07-2011, 07:58 AM
  5. Convert number to fixed length text field
    By tpcervelo in forum Queries
    Replies: 1
    Last Post: 08-02-2010, 07:26 PM

Tags for this Thread

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