Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
syntax error in VBA in query from Access | Excel Discussion (Misc queries) | |||
FILLING A RANGE WITH SAME CHARACTERS INVOLVING HIDDED ROWS | Excel Discussion (Misc queries) | |||
Error trying to run a query in Access from macro in Excel | Excel Programming | |||
Access query to specific cells | Excel Programming | |||
Type Mismatch Error help understanding | Excel Programming |