Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Problem writing numbers and dates to spreadsheet using ADO

When I write numbers, dates or currency values to an Excel file using
ADO (VB6) there is a little green mark at the top left of each column
indicating there is an error with the data. When I click on the cell I
get a small exclamation mark pops up to the left. I click on it and it
shows a drop down which provides the following selections:
"Number Stored as Text"
"Convert to Number"
"Help on this Error"
"Ignore Error:"
"Edit in Formula Bar"
"Error Checking Options"
"Show Formula Auditing Toolbar"

Apparently Excel thinks there is a problem with the data. But all I
have to do to correct the problem and get rid of the little green mark
at the top left corner of the cell is click in the formula bar and the
click out. So there really isn't a problem (the cell is formated as
"General" so numbers or dates should work as well as anything else).
Here is the code I use.

With objConn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & strExcelFile & "; Extended
Properties=Excel 8.0"
.Open
End With

rs.Open "select * from [Sheet1$]", objConn, adOpenKeyset,
adLockOptimistic

mrsPrepaidQuotes.MoveFirst ' mrsPrepaidQuotes is an ado recordset
from a mssql2000 db
While Not mrsPrepaidQuotes.EOF
rs.AddNew
rs.Fields("OriginalOrderDate") = DateOnly(mrsPrepaidQuotes!
OriginalOrderDate) 'returns a data string "07/07/2006" - Has the
little green thing in corner
rs.Fields("OriginalS#") =
mrsPrepaidQuotes.Fields("OriginalS#").Value ' returns a letter and
numbers ' no prob
rs.Fields("Quote#") = mrsPrepaidQuotes.Fields("Quote#").Value '
returns a letter and numbers ' no prob
rs.Fields("CustomerNumber") =
mrsPrepaidQuotes.Fields("CustomerNumber").Value ' returns a number, as
green thing
rs.Fields("Amt") = FormatCurrency(mrsPrepaidQuotes!Amt) ' return
currency string "$100.00" also has green thing
rs.Fields("Amt w/Tax") =
FormatCurrency(mrsPrepaidQuotes.Fields("Amt w/Tax").Value) return
currency string "$100.00" also has green thing
mrsPrepaidQuotes.MoveNext
Wend
rs.Update

Thanks in advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
MaC MaC is offline
external usenet poster
 
Posts: 8
Default Problem writing numbers and dates to spreadsheet using ADO

If we talk about numbers, I guess the green thing can be made by the Excel
error checking options.
Maybe just try to run your code after turning of this option, e.g.:
Application.ErrorCheckingOptions.NumberAsText = false

Regards
Mariusz

Uzytkownik "Jesse Hogan" napisal w wiadomosci
ups.com...
When I write numbers, dates or currency values to an Excel file using
ADO (VB6) there is a little green mark at the top left of each column
indicating there is an error with the data. When I click on the cell I
get a small exclamation mark pops up to the left. I click on it and it
shows a drop down which provides the following selections:
"Number Stored as Text"
"Convert to Number"
"Help on this Error"
"Ignore Error:"
"Edit in Formula Bar"
"Error Checking Options"
"Show Formula Auditing Toolbar"

Apparently Excel thinks there is a problem with the data. But all I
have to do to correct the problem and get rid of the little green mark
at the top left corner of the cell is click in the formula bar and the
click out. So there really isn't a problem (the cell is formated as
"General" so numbers or dates should work as well as anything else).
Here is the code I use.

With objConn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & strExcelFile & "; Extended
Properties=Excel 8.0"
.Open
End With

rs.Open "select * from [Sheet1$]", objConn, adOpenKeyset,
adLockOptimistic

mrsPrepaidQuotes.MoveFirst ' mrsPrepaidQuotes is an ado recordset
from a mssql2000 db
While Not mrsPrepaidQuotes.EOF
rs.AddNew
rs.Fields("OriginalOrderDate") = DateOnly(mrsPrepaidQuotes!
OriginalOrderDate) 'returns a data string "07/07/2006" - Has the
little green thing in corner
rs.Fields("OriginalS#") =
mrsPrepaidQuotes.Fields("OriginalS#").Value ' returns a letter and
numbers ' no prob
rs.Fields("Quote#") = mrsPrepaidQuotes.Fields("Quote#").Value '
returns a letter and numbers ' no prob
rs.Fields("CustomerNumber") =
mrsPrepaidQuotes.Fields("CustomerNumber").Value ' returns a number, as
green thing
rs.Fields("Amt") = FormatCurrency(mrsPrepaidQuotes!Amt) ' return
currency string "$100.00" also has green thing
rs.Fields("Amt w/Tax") =
FormatCurrency(mrsPrepaidQuotes.Fields("Amt w/Tax").Value) return
currency string "$100.00" also has green thing
mrsPrepaidQuotes.MoveNext
Wend
rs.Update

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Problem writing numbers and dates to spreadsheet using ADO

the data is stored as text. When you edit it, it is reevaluated and stored
as number and thus since it is a number, excel is no longer concerned.

--
Regards,
Tom Ogilvy


"Jesse Hogan" wrote:

When I write numbers, dates or currency values to an Excel file using
ADO (VB6) there is a little green mark at the top left of each column
indicating there is an error with the data. When I click on the cell I
get a small exclamation mark pops up to the left. I click on it and it
shows a drop down which provides the following selections:
"Number Stored as Text"
"Convert to Number"
"Help on this Error"
"Ignore Error:"
"Edit in Formula Bar"
"Error Checking Options"
"Show Formula Auditing Toolbar"

Apparently Excel thinks there is a problem with the data. But all I
have to do to correct the problem and get rid of the little green mark
at the top left corner of the cell is click in the formula bar and the
click out. So there really isn't a problem (the cell is formated as
"General" so numbers or dates should work as well as anything else).
Here is the code I use.

With objConn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & strExcelFile & "; Extended
Properties=Excel 8.0"
.Open
End With

rs.Open "select * from [Sheet1$]", objConn, adOpenKeyset,
adLockOptimistic

mrsPrepaidQuotes.MoveFirst ' mrsPrepaidQuotes is an ado recordset
from a mssql2000 db
While Not mrsPrepaidQuotes.EOF
rs.AddNew
rs.Fields("OriginalOrderDate") = DateOnly(mrsPrepaidQuotes!
OriginalOrderDate) 'returns a data string "07/07/2006" - Has the
little green thing in corner
rs.Fields("OriginalS#") =
mrsPrepaidQuotes.Fields("OriginalS#").Value ' returns a letter and
numbers ' no prob
rs.Fields("Quote#") = mrsPrepaidQuotes.Fields("Quote#").Value '
returns a letter and numbers ' no prob
rs.Fields("CustomerNumber") =
mrsPrepaidQuotes.Fields("CustomerNumber").Value ' returns a number, as
green thing
rs.Fields("Amt") = FormatCurrency(mrsPrepaidQuotes!Amt) ' return
currency string "$100.00" also has green thing
rs.Fields("Amt w/Tax") =
FormatCurrency(mrsPrepaidQuotes.Fields("Amt w/Tax").Value) return
currency string "$100.00" also has green thing
mrsPrepaidQuotes.MoveNext
Wend
rs.Update

Thanks in advance.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Problem writing numbers and dates to spreadsheet using ADO

MaC
You are right about why the little green triangle gets displayed. I
can turn this option off if I adjust the Error Checking options in
Excel. Since I am using ADO and not Excel Automation I can't do this:
Application.ErrorCheckingOptions.NumberAsText = false (technical
reasons prevent me from doing automation).
So this is weird, it would appear that I can't use ADO to write to an
Excel file numbers, dates or currencies without incurring that little
green triangle. I've looked all over the Internet for code examples of
how others have dealt with this and can't find anything. It wouldn't
bother me so much but I need this report to be automatically sent to
our client and I would rather them not see all these green little
triangles in almost all the cells.

Thanks for you help though

On May 4, 1:24 pm, Tom Ogilvy
wrote:
the data is stored as text. When you edit it, it is reevaluated and stored
as number and thus since it is a number, excel is no longer concerned.

--
Regards,
Tom Ogilvy

"JesseHogan" wrote:
When I write numbers, dates or currency values to an Excel file using
ADO (VB6) there is a little green mark at the top left of each column
indicating there is an error with the data. When I click on the cell I
get a small exclamation mark pops up to the left. I click on it and it
shows a drop down which provides the following selections:
"Number Stored as Text"
"Convert to Number"
"Help on this Error"
"Ignore Error:"
"Edit in Formula Bar"
"Error Checking Options"
"Show Formula Auditing Toolbar"


Apparently Excel thinks there is a problem with the data. But all I
have to do to correct the problem and get rid of the little green mark
at the top left corner of the cell is click in the formula bar and the
click out. So there really isn't a problem (the cell is formated as
"General" so numbers or dates should work as well as anything else).
Here is the code I use.


With objConn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & strExcelFile & "; Extended
Properties=Excel 8.0"
.Open
End With


rs.Open "select * from [Sheet1$]", objConn, adOpenKeyset,
adLockOptimistic


mrsPrepaidQuotes.MoveFirst ' mrsPrepaidQuotes is an ado recordset
from a mssql2000 db
While Not mrsPrepaidQuotes.EOF
rs.AddNew
rs.Fields("OriginalOrderDate") = DateOnly(mrsPrepaidQuotes!
OriginalOrderDate) 'returns a data string "07/07/2006" - Has the
little green thing in corner
rs.Fields("OriginalS#") =
mrsPrepaidQuotes.Fields("OriginalS#").Value ' returns a letter and
numbers ' no prob
rs.Fields("Quote#") = mrsPrepaidQuotes.Fields("Quote#").Value '
returns a letter and numbers ' no prob
rs.Fields("CustomerNumber") =
mrsPrepaidQuotes.Fields("CustomerNumber").Value ' returns a number, as
green thing
rs.Fields("Amt") = FormatCurrency(mrsPrepaidQuotes!Amt) ' return
currency string "$100.00" also has green thing
rs.Fields("Amt w/Tax") =
FormatCurrency(mrsPrepaidQuotes.Fields("Amt w/Tax").Value) return
currency string "$100.00" also has green thing
mrsPrepaidQuotes.MoveNext
Wend
rs.Update


Thanks in advance.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing a macro that will exit a spreadsheet Dave Doc New Users to Excel 2 January 26th 06 01:41 PM
VBA UDF Writing data to spreadsheet Macroman Excel Programming 4 April 17th 05 10:51 AM
Writing Out Numbers as Text [email protected] Excel Programming 1 October 11th 04 09:35 PM
Writing bitmap to Excel Spreadsheet Macca Excel Programming 0 September 21st 04 02:41 PM
Writing to a excel spreadsheet is slow. Pat Lenahan Excel Programming 5 November 19th 03 08:33 PM


All times are GMT +1. The time now is 02:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"