Solved

Excel output from Access VBA

Posted on 2015-02-20
3
89 Views
Last Modified: 2016-02-10
I have an Access VBA application that writes to an Excel spreadsheet.  I have a serial number field that is a text field in access and contains alphanumeric data.  There are some that are numeric only and if the number is large, it appears on the spreadsheet as a scientific notation. (eg.  5.30559E+12 instead of 5305588100056).  I have tried everything I can think of to force it to always print just as text.
In my code I have:
strSerialNumber = Nz(!SerialNumber, "")
.....
objXLS.Cells(intRow, 4).Value = RTrim$(strSerialNumber)
objXLS.Cells(intRow, 4).NumberFormat = "@"
....
    objXLS.ActiveWorkbook.SaveAs strfile
Any help if forcing the serial number to always display as text would be appreciated.
Thanks
Art...
0
Comment
Question by:ajwellman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40621251
Why not have, instead of your second line, this:

objXLS.Cells(intRow, 4).Value = "'" & RTrim$(strSerialNumber)

That ' should force it as text.
0
 
LVL 34

Accepted Solution

by:
Norie earned 500 total points
ID: 40621265
Have you tried setting the NumberFormat before putting the value in the cell?
0
 

Author Closing Comment

by:ajwellman
ID: 40621614
Thanks Norie.   This worked great.  I had tried putting a character in front to force, but couldn't change the serial in any way.
Thanks again for such a quick solution.
Art
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Viewers will learn the basics of printing in Excel 2013 and how to adjust some common settings.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question