Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Help understanding truely strange error involving access query and filling cells

An excel application I'm working on has developed a truely strange bug
that I'm having difficulty getting a handle on ... it is filling an
entire sheet with the number 53 for no apparent reason!?!?

The application queries an Access database with code like this:

Function Qry(tllocation As Range, sql As String) As Long
Dim db As DAO.Database
Dim rs As DAO.Recordset

application.ThisWorkbook.Activate
Set db = OpenDatabase(ThisWorkbook.Path & "\MMR.mDB")
Set rs = db.OpenRecordset(sql)
rows = tllocation.cells(2, 1).CopyFromRecordset(rs)
db.Close
Set db = Nothing
Set rs = Nothing
Exit Function
End Function

The query retrievs 53 records (break point on Exit alows examination).
While sitting on the breakpoint the spreadsheet exhibits the expected
records. HOWEVER, a single step takes a long time during which the
status line displays "Filling Cells". When control returns to the
calling UDF ALL the sheet's cells contain 53!

I'm truely mystified. Has anyone any clues?

Thanks for any help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Help understanding truely strange error involving access query and filling cells

Sometimes excel makes me just crazy ...

The calling code lookes like this

rows = Qry( ... )

and I had not declared rows (BAD puff). Now rows in this context is a
range containing ALL the rows on the active worksheet. Qry returns
it's record count, 53 and excel happily fills every cell of every row
with the value.

I shall now go and repeat over and over and over again "Thou shalt Dim
ALL your variables always. Thou shalt NOT use excell works ever!"

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
syntax error in VBA in query from Access Winget Excel Discussion (Misc queries) 0 January 21st 10 07:49 PM
FILLING A RANGE WITH SAME CHARACTERS INVOLVING HIDDED ROWS CCCN_PARTNER Excel Discussion (Misc queries) 1 September 17th 07 06:38 PM
Error trying to run a query in Access from macro in Excel Pete[_24_] Excel Programming 0 November 3rd 05 07:50 PM
Access query to specific cells Cyberwolf Excel Programming 1 July 8th 05 08:27 PM
Type Mismatch Error help understanding Ray Batig Excel Programming 5 January 3rd 04 03:07 AM


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

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

About Us

"It's about Microsoft Excel"