Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Eagle Eyes!!! Why Error 3061 in such a simple statement????

Status
Not open for further replies.

waldemar

Programmer
Nov 15, 2001
245
DE
Well Error 3601 seems to appear when one sets a recordset Object with table fields that do not exist (keyword 'missspellig')...

But what's wrong with this one???

Set rsInvoices = CurrentDb.OpenRecordset("SELECT * FROM [sqlInvoicesForInvoices];", dbOpenDynaset)

...while the query sqlInvoicesForInvoices works fine when I open in the database window (no form fields references or anything....)

AM I BLIND???????
 
Since sqlInvoicesForInvoices is a query, then try this:
Set rsInvoices = CurrentDb.OpenRecordset ("sqlInvoicesForInvoices")
 
Thanks for the suggestion.... But... Nope... still this error...

I tried the underlying table (tblInvoices) instead and (as expected jesuschrist is this ridiculous) of course it worked.

This means the problem is inside the query?

SELECT * FROM tblClients INNER JOIN ((tblInvoicesClientsData INNER JOIN tblInvoices ON tblInvoicesClientsData.strClientID = tblInvoices.strClientID) INNER JOIN tblUserInvoicesSelection ON tblInvoices.strInvoiceID = tblUserInvoicesSelection.strInvoiceID) ON tblClients.strClientID = tblInvoicesClientsData.strClientID WHERE (((tblUserInvoicesSelection.strUserID)=[application].[currentuser]));

???
 
Hi,

I used your query with DAO 3.6 and your code and it worked without error. Here's the query which I think is exactly as your is:

=====================
SELECT *
FROM tblClients INNER JOIN ((tblInvoicesClientsData INNER JOIN tblInvoices ON tblInvoicesClientsData.strClientID = tblInvoices.strClientID) INNER JOIN tblUserInvoicesSelection ON tblInvoices.strInvoiceID = tblUserInvoicesSelection.strInvoiceID) ON tblClients.strClientID = tblInvoicesClientsData.strClientID
WHERE (((tblUserInvoicesSelection.strUserID)=[application].[currentuser]));
======================

Dim rsInvoices As Recordset

'Using DAO 3.6
Set rsInvoices = CurrentDb.OpenRecordset("SELECT * FROM [sqlInvoicesForInvoices];", dbOpenDynaset)
If rsInvoices.RecordCount > 0 Then MsgBox "recs"
Set rsInvoices = Nothing

Have a good one!
BK
 
Hi again,

When I tried it using ADO 2.1 it gave me error 3001 (type mismatch) I haven't been able to reproduce the 3601 error.

Have a good one!
BK
 
You rebuilt the tables and id fields?

Strange... I'm using only DAO 3.6 (MS Jet 4.0 ServicePack 6 Q320176) and even something as simple as

Function testtest()
Dim rs As Recordset
Set rsInvoices = CurrentDb.OpenRecordset("SELECT * FROM [sqlInvoicesForInvoices];", dbOpenDynaset)
End Function

produces 3601.
 
Change your statements to:

Dim rsInvoices as Recordset
Set rsInvoices = DBEngine(0)(0).OpenRecordset("SELECT * FROM sqlInvoicesForInvoices;", dbOpenDynaset)
 
I may be wrong but believe the following will correct the error. dbOpenDynaset is not required since that is the default type. I get the 3061 error occasionally so I build it using the query builder and use the result.

"SELECT sqlInvoicesForInvoice.* FROM sqlInvoicesForInvoices;"

----------------------
scking@arinc.com
Life is filled with lessons.
We are responsible for the
results of the quizzes.
-----------------------
 
john, scking: Tried both approaches, sill 3601...

Right now this looks to me this is a special situation error on my system?? You guys say the query and the recordset opening work fine for you...

It can not be the query itself, since it works in all forms and all reports here... what is going on??? Is this a bug? A feaure? The application's size is currently at 5 MB size.... maybe Access collapses at some point??? :))
 
Well indead it was the query! :)

And the solution:

Object References à la "[application].[CurrentUser]" that work perfectly inside a regular QBD Query have to be rebuilt in VBA:

("...WHERE (((tblUserInvoicesSelection.strUserID)=[application].[currentuser]));", dbOpenDynaset)

turns into:

("...WHERE (((tblUserInvoicesSelection.strUserID)='" & Application.CurrentUser & "'));", dbOpenDynaset)

:)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top