PC Review


Reply
Thread Tools Rate Thread

data type conversion when automating excel from access

 
 
=?Utf-8?B?VGFueWE=?=
Guest
Posts: n/a
 
      1st Aug 2007
To all,

I'm working on automating data from a query in Access to Excel and having a
difficulty in formatting the data.

Basically, I want to display any zip code that begins with zero as a text in
Excel from Access. Does anyone know how to do that? I really appreciate your
help. Thanks!
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGFvbG8=?=
Guest
Posts: n/a
 
      1st Aug 2007
Hi Tanya,
in the query you use to export the data from access to XL add a cstr to the
field you wanna be exported as text. e.g. zip: cstr(zip code)

HTH Paolo

"Tanya" wrote:

> To all,
>
> I'm working on automating data from a query in Access to Excel and having a
> difficulty in formatting the data.
>
> Basically, I want to display any zip code that begins with zero as a text in
> Excel from Access. Does anyone know how to do that? I really appreciate your
> help. Thanks!

 
Reply With Quote
 
=?Utf-8?B?VGFueWE=?=
Guest
Posts: n/a
 
      1st Aug 2007
I tried to put "" or cstr in front of the expression but it doesn't work.

However, surprisingly Excel displays the data as a text, when I tried to put
a single quote concatenate with the expression on my VBA code in Access.

Thanks Ed and Paolo for your advice.

"Ed Adamthwaite" wrote:

> Hi Tania
> To have leading zeros in Excel they must be prefixed with a quote "'".
> When entering the data into a cell, do something like:
>
> If rs.Fields(i).Name = "Zipcode" then
> Cells(RowNum,ColumNum) = "'" & rs.Fields(i)
> Else
> Cells(RowNum,ColumNum) = rs.Fields(i)
> End If
>
> Regards,
> Ed.
>
> "Tanya" <(E-Mail Removed)> wrote in message
> news:8CB66D8F-D002-4488-A1EF-(E-Mail Removed)...
> > To all,
> >
> > I'm working on automating data from a query in Access to Excel and having
> > a
> > difficulty in formatting the data.
> >
> > Basically, I want to display any zip code that begins with zero as a text
> > in
> > Excel from Access. Does anyone know how to do that? I really appreciate
> > your
> > help. Thanks!

>

 
Reply With Quote
 
=?Utf-8?B?UGFvbG8=?=
Guest
Posts: n/a
 
      1st Aug 2007
Hey Tanya,
I would say no surprise 'cause the single quote is the indicator for XL to
"understand" the expression as a text... is what Ed told you
You can use the cstr before the field, as I told you, if you export a saved
query (and you put the cstr in front of the field in the query structure) to
XL but if you work in VBA the single quote is the best way.
Regards Paolo

"Tanya" wrote:

> I tried to put "" or cstr in front of the expression but it doesn't work.
>
> However, surprisingly Excel displays the data as a text, when I tried to put
> a single quote concatenate with the expression on my VBA code in Access.
>
> Thanks Ed and Paolo for your advice.
>
> "Ed Adamthwaite" wrote:
>
> > Hi Tania
> > To have leading zeros in Excel they must be prefixed with a quote "'".
> > When entering the data into a cell, do something like:
> >
> > If rs.Fields(i).Name = "Zipcode" then
> > Cells(RowNum,ColumNum) = "'" & rs.Fields(i)
> > Else
> > Cells(RowNum,ColumNum) = rs.Fields(i)
> > End If
> >
> > Regards,
> > Ed.
> >
> > "Tanya" <(E-Mail Removed)> wrote in message
> > news:8CB66D8F-D002-4488-A1EF-(E-Mail Removed)...
> > > To all,
> > >
> > > I'm working on automating data from a query in Access to Excel and having
> > > a
> > > difficulty in formatting the data.
> > >
> > > Basically, I want to display any zip code that begins with zero as a text
> > > in
> > > Excel from Access. Does anyone know how to do that? I really appreciate
> > > your
> > > help. Thanks!

> >

 
Reply With Quote
 
=?Utf-8?B?VGFueWE=?=
Guest
Posts: n/a
 
      1st Aug 2007
Thank you!

"Paolo" wrote:

> Hey Tanya,
> I would say no surprise 'cause the single quote is the indicator for XL to
> "understand" the expression as a text... is what Ed told you
> You can use the cstr before the field, as I told you, if you export a saved
> query (and you put the cstr in front of the field in the query structure) to
> XL but if you work in VBA the single quote is the best way.
> Regards Paolo
>
> "Tanya" wrote:
>
> > I tried to put "" or cstr in front of the expression but it doesn't work.
> >
> > However, surprisingly Excel displays the data as a text, when I tried to put
> > a single quote concatenate with the expression on my VBA code in Access.
> >
> > Thanks Ed and Paolo for your advice.
> >
> > "Ed Adamthwaite" wrote:
> >
> > > Hi Tania
> > > To have leading zeros in Excel they must be prefixed with a quote "'".
> > > When entering the data into a cell, do something like:
> > >
> > > If rs.Fields(i).Name = "Zipcode" then
> > > Cells(RowNum,ColumNum) = "'" & rs.Fields(i)
> > > Else
> > > Cells(RowNum,ColumNum) = rs.Fields(i)
> > > End If
> > >
> > > Regards,
> > > Ed.
> > >
> > > "Tanya" <(E-Mail Removed)> wrote in message
> > > news:8CB66D8F-D002-4488-A1EF-(E-Mail Removed)...
> > > > To all,
> > > >
> > > > I'm working on automating data from a query in Access to Excel and having
> > > > a
> > > > difficulty in formatting the data.
> > > >
> > > > Basically, I want to display any zip code that begins with zero as a text
> > > > in
> > > > Excel from Access. Does anyone know how to do that? I really appreciate
> > > > your
> > > > help. Thanks!
> > >

 
Reply With Quote
 
Ed Adamthwaite
Guest
Posts: n/a
 
      2nd Aug 2007
Hi Tania
To have leading zeros in Excel they must be prefixed with a quote "'".
When entering the data into a cell, do something like:

If rs.Fields(i).Name = "Zipcode" then
Cells(RowNum,ColumNum) = "'" & rs.Fields(i)
Else
Cells(RowNum,ColumNum) = rs.Fields(i)
End If

Regards,
Ed.

"Tanya" <(E-Mail Removed)> wrote in message
news:8CB66D8F-D002-4488-A1EF-(E-Mail Removed)...
> To all,
>
> I'm working on automating data from a query in Access to Excel and having
> a
> difficulty in formatting the data.
>
> Basically, I want to display any zip code that begins with zero as a text
> in
> Excel from Access. Does anyone know how to do that? I really appreciate
> your
> help. Thanks!


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data type Conversion from Excel inconsistency =?Utf-8?B?UmFjZXI0OQ==?= Microsoft Access Macros 2 4th Oct 2007 12:56 AM
Type Conversion Failure in Access 2003 when importing from Excel =?Utf-8?B?d29jcnVj?= Microsoft Access External Data 2 18th Apr 2006 11:30 PM
?Type conversion failure when importing excel to access =?Utf-8?B?SmF5bGlu?= Microsoft Access External Data 9 1st Mar 2006 06:07 PM
Data type conversion from Excel Jon Microsoft Access External Data 5 17th Aug 2005 10:14 PM
Excel VBA - Data Type Conversion problem PaulC Microsoft Excel Programming 3 10th May 2004 05:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:24 PM.