M
Michael Dorovitsine
I encountered special behaviour in Access (any version -
97, 2k, xp). If I have a table with some update
restrictions (like primary key), then error message is
not displayed if database is opened through
CreateObject/OpenCurrentDatabase.
Here is how to replicate it: create new access database,
create table "tbl" with column c1, number, c2 text, make
c1 primary key. Enter few values in the table like 0,
lkjh; 1, kjhg; 2, kjhg. Try to update record with c1 = 0
to value 1, you will get error message "update failed".
Now, run this code (from VB or Access VBA), make sure DAO
is referenced:
Option Explicit
Function TryThis()
Dim appAccess As Access.Application
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase "C:\dev\tmp1.mdb"
appAccess.Visible = True
End Function
Substitute "C:\dev\tmp1.mdb" by your database
Now, try to open table "tbl" and update c1 = 0 to be 1,
no errors, it just does not let you, but no information!
I tried OpenCurrentDatabase with exclusive, same
behaviour.
How to make users to see errors?
Michael.
97, 2k, xp). If I have a table with some update
restrictions (like primary key), then error message is
not displayed if database is opened through
CreateObject/OpenCurrentDatabase.
Here is how to replicate it: create new access database,
create table "tbl" with column c1, number, c2 text, make
c1 primary key. Enter few values in the table like 0,
lkjh; 1, kjhg; 2, kjhg. Try to update record with c1 = 0
to value 1, you will get error message "update failed".
Now, run this code (from VB or Access VBA), make sure DAO
is referenced:
Option Explicit
Function TryThis()
Dim appAccess As Access.Application
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase "C:\dev\tmp1.mdb"
appAccess.Visible = True
End Function
Substitute "C:\dev\tmp1.mdb" by your database
Now, try to open table "tbl" and update c1 = 0 to be 1,
no errors, it just does not let you, but no information!
I tried OpenCurrentDatabase with exclusive, same
behaviour.
How to make users to see errors?
Michael.