DBQuery on Excel Sheet - Numbers Ignored

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
dafe
Junior Coder
Posts: 23
Joined: Sun Apr 06, 2008 4:21 am

DBQuery on Excel Sheet - Numbers Ignored

Post by dafe » Thu Sep 11, 2008 9:02 am

I'm running the below macro on one of my excel spreadsheets. For some reason it is grabbing all the fields *except* for the fields that are just numbers.

As a test i did a MessageModal>StockSheet_10_13 which is one of the fields that stores a number. The resulting messagebox is blank. If I add a letter in front of the number in field _10_13 the message box displays the result perfectly.

Would anyone know the cause of this behaviour?

Code: Select all

Let>connStr=Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\StockPOS\Test.xls;Extended Properties="Excel 8.0;Hdr=No;"
DBConnect>connStr,dbH

Let>SQL=select * from [Sheet1$]
DBQuery>dbH,SQL,StockSheet,nR,nF

DBClose>dbH

Let>StrResult=Start
Let>r=0
Repeat>r
  Let>r=r+1
  Let>f=0
  Repeat>f
    Let>f=f+1
    Let>this_field=StockSheet_%r%_%f%
    Concat>StrResult,this_field
  Until>f=nF
Until>r=nR

MessageModal>StrResult
--

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Sep 11, 2008 9:11 am

You may have some mixed formats in the column. See this thread:
http://www.mjtnet.com/forum/viewtopic.php?p=20687
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

dafe
Junior Coder
Posts: 23
Joined: Sun Apr 06, 2008 4:21 am

Post by dafe » Thu Sep 11, 2008 9:29 am

Thanks & sorry for reposting an already answered question
--

edauthier
Pro Scripter
Posts: 84
Joined: Sun Apr 13, 2003 1:26 pm
Location: USA

Post by edauthier » Thu Oct 02, 2008 9:29 pm


Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts