I have a program that allows the user to select a category from a list box. All items from the category are then retrieved from the database and put into a second listbox. It worked fine until recently. The first listbox is filled correctly but when I want to fill the second one I get the following message:


I am sure that it is not my code that is causing the problem because it used to work. Maybe something has changed with the database but I can still open it in excel so it hasnt been password-protected.

This is the code I use to open the database:

Function Compland(SQLQuery As String, Jaar As Integer) As ADODB.Recordset

Dim Database As ADODB.Connection
Dim Bestand As ADODB.Recordset
Set Database = New ADODB.Connection

Database.ConnectionString = "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=" & databaselocation & ";adLockReadOnly "
Set Bestand = New ADODB.Recordset

With Bestand
    .CursorLocation = adUseClient
    .LockType = adLockReadOnly
    'Deze instelling heeft invloed op de snelheid
    'Oude waarde:adOpenStatic
    .CursorType = adOpenForwardOnly
    Call Database.Open
    Set .ActiveConnection = Database
    Call .Open(SQLQuery)
    Set .ActiveConnection = Nothing
End With

Set Compland = Bestand

End Function
I did some more research and I found out that it is possible to select the entire database or separate columns but as soon as I use WHERE the error occurs:

"SELECT * FROM database" works fine
"SELECT * FROM database WHERE column1='value'" doesnt work