recordset of query not read data (1 Viewer)

fvdb

Registered User.
Local time
Today, 22:35
Joined
Aug 24, 2015
Messages
67
Hi all,

I have a query wich is filtered by a listbox on a form.

When i open the query it shows me the results i need.

If a open de query from VBA i get error 3061 and the query not shows data.

The main use of this is to put some data in an excel sheet so we can send to other people. If i not put the filter it works normally

Code:
 Private Sub Knop20_Click()
    Dim objXL As Object
    Dim xlWB As Object
    Dim xlWS As Object
    Dim rst As DAO.Recordset
    Dim lngCount As Long
    On Error GoTo Errorhandling
    
        Set objXL = CreateObject("Excel.Application")
        objXL.Visible = True
               
        'Datapunten
        Set xlWS = xlWB.Worksheets("Datapunten")
        
        Set rst = CurrentDb.OpenRecordset("qry_Excel_Export")
 
        aantal_rijen = DCount("*", "qry_Excel_Export") - 1
         '   Open it
         
        With xlWS
            For i = 0 To aantal_rijen
            .Cells(1, 9).Select
            .Rows("9:9").Select
            Selection.Insert Shift:=xlDown
            Next i
        End With
 
        lngCount = 9
         
        Do Until rst.EOF
        
            With xlWS
                 .Cells(lngCount, 1).Value = rst!Component
                 .Cells(lngCount, 2).Value = rst!OMSCH
                 .Cells(lngCount, 3).Value = rst!AI
                 .Cells(lngCount, 4).Value = rst!AO
                 .Cells(lngCount, 5).Value = rst!DI
                 .Cells(lngCount, 6).Value = rst!DO
                 .Cells(lngCount, 7).Value = rst!BUS
                 .Cells(lngCount, 8).Value = rst!Veldregelaar
                 .Cells(lngCount, 9).Value = rst!OPMERKING
                 .Cells(lngCount, 11).Value = rst!datapunten
                 .Cells(lngCount, 12).Value = rst!Indienstname
                 .Cells(lngCount, 13).Value = rst!Totaal
            End With
            lngCount = lngCount + 1
            rst.MoveNext
        Loop
 
rst.Close
Set rst = Nothing
Exit Sub
 Errorhandling:
     MsgBox Err.Number & Err.Description
 
End Sub
 

fvdb

Registered User.
Local time
Today, 22:35
Joined
Aug 24, 2015
Messages
67
in attachment the database and necessary files.

Extract to C: drive to let it work
 

Attachments

  • TD GBS.zip
    639.6 KB · Views: 43

spikepl

Eledittingent Beliped
Local time
Today, 22:35
Joined
Nov 3, 2010
Messages
6,142
google access error 3061

very common
 

fvdb

Registered User.
Local time
Today, 22:35
Joined
Aug 24, 2015
Messages
67
Solved.

My mistake i didn't use google before. I thought i did something wrong in the query. Solved it with a 'querydef'
 

Users who are viewing this thread

Top Bottom