Results 1 to 3 of 3

Thread: Problem with data format in Excel

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    39

    Problem with data format in Excel

    Hi, I am moving some data from an Access database to an Excel file with:
    VB Code:
    1. oXLSheet.Range("A2").CopyFromRecordset rstExcel
    I am having some troubles with the format data is displayed. With the columns that are "Date/Time"data type in the Access database I put:
    VB Code:
    1. oXLSheet.Columns("A:A").NumberFormat = "dd/MM/yyyy hh:mm:ss"
    in the visual basic code to move them in the correct format, and it works ok. But there are other columns that are "Number" data type in Access and when I move them to an excel file they appears like "27/02/1900"
    (I think 00/00/1900 corresponds to 0). I don´t understand why the program considers this data as dates instead of numbers. I have tried:
    VB Code:
    1. oXLSheet.Columns("B:B").NumberFormat = "0"
    but it doesnt work. How could I get the data in the correct format? I have other columns in Access that are "Number" data type and they appear correctly in the Excel file Thank you very much for your help!!

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Problem with data format in Excel

    Moved to Office Development

    What kind of values are in the column(s) that arent shown properly?

    What happens if you try this format instead:
    VB Code:
    1. oXLSheet.Columns("B:B").NumberFormat = "General"

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    39

    Re: Problem with data format in Excel

    I have tried what you said:
    VB Code:
    1. oXLSheet.Columns("B:B").NumberFormat = "General"
    but the data is displayed again in the "27/02/1900" format. The values in these columns (I have 2 problematic columns) are numbers (positive integers), I can see them correctly if I open the Access database. In the table design the data type for these 2 columns is "Number". The most annoying thing is that I have other columns with the same data type and they are shown correctly in Excel. Moreover, sometimes the 2 problematic columns are shown correctly, but other times no (I don´t know why) so I would like to force these data to be displayed always in the correct data format if possible. Thanks for your help!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width