OpenRecordset ODBC error (1 Viewer)

Mirihika

New member
Local time
Today, 19:00
Joined
Feb 16, 2015
Messages
8
Can someone help please?

The code below should add a record to another table when a box is ticked. It worked fine when I wrote it in a local Access 2003 form.

I have since migrated the tables to Azure and connect via ODBC, and now I get this error:
OpenRecordsetBug.PNG

A search for Identities told me to modify the code as in the second screenshot, and I now have a different error:
InvalidArgument.JPG

What am I doing wrong?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 00:00
Joined
Aug 30, 2003
Messages
36,133
I think you have them reversed. This works for me:

Set rsMaster = db.OpenRecordset("SELECT...", dbOpenDynaset, dbSeeChanges)
 

Mirihika

New member
Local time
Today, 19:00
Joined
Feb 16, 2015
Messages
8
Thank you Paul. Yes, it works!

I can't remember any other instance where the order of what looks like a list of parameters mattered. Clearly the second parameter depends on the first so they aren't really a list.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 00:00
Joined
Aug 30, 2003
Messages
36,133
Happy to help!
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 17:00
Joined
Jan 20, 2009
Messages
12,856
I can't remember any other instance where the order of what looks like a list of parameters mattered. Clearly the second parameter depends on the first so they aren't really a list.

Either you have a bad memory, have not been around much or have been very lucky.;)

In any function, the parameters order is specific. They can't be just swapped around randomly. In the case of OpenRecordset the second parameter is RecordsetType while the third is RecordsetOption.

What you have probably seen working in some cases is the values of these enumerated parameters just happening to be workable even though you used the wrong one for the argument.

The enumerated parameters are actually a type of constant that stores a Long Integer.

For example dbOpenDynamic = 16 while dbSeeChanges = 512

When you put them backwards you are passing a value of 512 to RecordsetType and that value is rejected because it is not an allowed value.

Meanwhile passing dbOpenDynamic to RecordsetOption indicates the option usually indicated by dbInconsistent.
 

Users who are viewing this thread

Top Bottom