dbTalk Databases Forums  

converting to access2003 from access97

comp.databases.ms-access comp.databases.ms-access


Discuss converting to access2003 from access97 in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Roger
 
Posts: n/a

Default converting to access2003 from access97 - 07-26-2010 , 05:34 PM






I've got a function that relinks my tables from the development server
to the production server (sql server 2005)
some of the tables / views are third party, and have no PK, so to
improve access performance I create a PK using this function
Private Sub createIndex(strTable As String, strFields As String)
Dim strSql As String

On Error GoTo fErr
strSql = "CREATE INDEX PK ON [" & strTable & "] (" & strFields &
") WITH PRIMARY;"
CurrentDb.Execute strSql
fExit:
Exit Sub

fErr:
If (Err.Number <> 3283) Then
MsgBox "createIndex " & strSql, True
Resume fExit
Else
Resume Next
End If
End Sub

In access97, if the sql server table has a PK, the refreshLink()
function will create it in access, and the currentdb.execute() will
error out with error 3283 and resume

in access2003, instead of erroring out to fErr, it gives me a popup
box, "runtime error 3283, primary key already exists", "end or debug"

if I replace "on error goto ferr" with "on error resume next", the
same message box is displayed

if I do
dim db as dao.recordset
set db = currentDB
db.execute ...

same message box

any idea why it pops up a message box ?
any workaround ?

Reply With Quote
  #2  
Old   
Douglas J. Steele
 
Posts: n/a

Default Re: converting to access2003 from access97 - 07-26-2010 , 06:02 PM






Try replacing

CurrentDb.Execute strSql

with

CurrentDb.Execute strSql, dbFailOnError


--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/djsteele
Co-author: "Access 2010 Solutions", published by Wiley
(no e-mails, please!)



"Roger" <lesperancer (AT) natpro (DOT) com> wrote

Quote:
I've got a function that relinks my tables from the development server
to the production server (sql server 2005)
some of the tables / views are third party, and have no PK, so to
improve access performance I create a PK using this function
Private Sub createIndex(strTable As String, strFields As String)
Dim strSql As String

On Error GoTo fErr
strSql = "CREATE INDEX PK ON [" & strTable & "] (" & strFields &
") WITH PRIMARY;"
CurrentDb.Execute strSql
fExit:
Exit Sub

fErr:
If (Err.Number <> 3283) Then
MsgBox "createIndex " & strSql, True
Resume fExit
Else
Resume Next
End If
End Sub

In access97, if the sql server table has a PK, the refreshLink()
function will create it in access, and the currentdb.execute() will
error out with error 3283 and resume

in access2003, instead of erroring out to fErr, it gives me a popup
box, "runtime error 3283, primary key already exists", "end or debug"

if I replace "on error goto ferr" with "on error resume next", the
same message box is displayed

if I do
dim db as dao.recordset
set db = currentDB
db.execute ...

same message box

any idea why it pops up a message box ?
any workaround ?

Reply With Quote
  #3  
Old   
Roger
 
Posts: n/a

Default Re: converting to access2003 from access97 - 07-26-2010 , 06:44 PM



On Jul 26, 5:02*pm, "Douglas J. Steele"
<NOSPAM_djsteele (AT) NOSPAM_gmail (DOT) com> wrote:
Quote:
Try replacing

CurrentDb.Execute strSql

with

CurrentDb.Execute strSql, dbFailOnError

--
Doug Steele, Microsoft Access MVPhttp://www.AccessMVP.com/djsteele
Co-author: "Access 2010 Solutions", published by Wiley
(no e-mails, please!)

"Roger" <lesperan... (AT) natpro (DOT) com> wrote in message

news:80f8be63-766d-4127-9e47-04d34af6b8cf (AT) g19g2000yqc (DOT) googlegroups.com...



I've got a function that relinks my tables from the development server
to the production server (sql server 2005)
some of the tables / views are third party, and have no PK, so to
improve access performance I create a PK using this function
Private Sub createIndex(strTable As String, strFields As String)
* *Dim strSql As String

* *On Error GoTo fErr
* *strSql = "CREATE INDEX PK ON [" & strTable & "] (" & strFields&
") WITH PRIMARY;"
* *CurrentDb.Execute strSql
fExit:
* *Exit Sub

fErr:
* *If (Err.Number <> 3283) Then
* * * *MsgBox "createIndex " & strSql, True
* * * *Resume fExit
* *Else
* * * *Resume Next
* *End If
End Sub

In access97, if the sql server table has a PK, the refreshLink()
function will create it in access, and the currentdb.execute() *will
error out with error 3283 and resume

in access2003, instead of erroring out to fErr, it gives me a popup
box, "runtime error 3283, primary key already exists", "end or debug"

if I replace "on error goto ferr" with "on error resume next", the
same message box is displayed

if I do
* *dim db as dao.recordset
* set db = currentDB
* db.execute ...

* same message box

any idea why it pops up a message box ?
any workaround ?- Hide quoted text -

- Show quoted text -
nope, same message box

Reply With Quote
  #4  
Old   
The Frog
 
Posts: n/a

Default Re: converting to access2003 from access97 - 07-27-2010 , 07:10 AM



How about checking the primary keys first?

SELECT
TABLE_SCHEMA,
TABLE_NAME,
CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE CONSTRAINT_TYPE = 'PRIMARY KEY'
ORDER BY
TABLE_SCHEMA,
TABLE_NAME

This will give you the PK's from SQL Server. You can then apply
whatever logic you want after that...

Cheers

The Frog

Reply With Quote
  #5  
Old   
Roger
 
Posts: n/a

Default Re: converting to access2003 from access97 - 07-27-2010 , 08:55 AM



On Jul 27, 6:10*am, The Frog <mr.frog.to.... (AT) googlemail (DOT) com> wrote:
Quote:
How about checking the primary keys first?

SELECT
TABLE_SCHEMA,
TABLE_NAME,
CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE CONSTRAINT_TYPE = 'PRIMARY KEY'
ORDER BY
TABLE_SCHEMA,
TABLE_NAME

This will give you the PK's from SQL Server. You can then apply
whatever logic you want after that...

Cheers

The Frog
good idea, but I checked in access using
Private Function pkExists(strTable As String) As Boolean
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim idx As DAO.Index

On Error GoTo fErr
pkExists = False
Set db = CurrentDb
Set tdf = db.TableDefs(strTable)
For Each idx In tdf.Indexes
If (idx.Primary) Then
pkExists = True
Exit For
End If
Next

fExit:
On Error Resume Next
Set idx = Nothing
Set tdf = Nothing
Set db = Nothing
Exit Function

fErr:
errorLog "pkExists " & strTable
Resume fExit
End Function

Reply With Quote
  #6  
Old   
Roger
 
Posts: n/a

Default Re: converting to access2003 from access97 - 07-27-2010 , 06:27 PM



On Jul 27, 7:55*am, Roger <lesperan... (AT) natpro (DOT) com> wrote:
Quote:
On Jul 27, 6:10*am, The Frog <mr.frog.to.... (AT) googlemail (DOT) com> wrote:





How about checking the primary keys first?

SELECT
TABLE_SCHEMA,
TABLE_NAME,
CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE CONSTRAINT_TYPE = 'PRIMARY KEY'
ORDER BY
TABLE_SCHEMA,
TABLE_NAME

This will give you the PK's from SQL Server. You can then apply
whatever logic you want after that...

Cheers

The Frog

good idea, but I checked in access using
Private Function pkExists(strTable As String) As Boolean
* * Dim db As DAO.Database
* * Dim tdf As DAO.TableDef
* * Dim idx As DAO.Index

* * On Error GoTo fErr
* * pkExists = False
* * Set db = CurrentDb
* * Set tdf = db.TableDefs(strTable)
* * For Each idx In tdf.Indexes
* * * * If (idx.Primary) Then
* * * * * * pkExists = True
* * * * * * Exit For
* * * * End If
* * Next

fExit:
* * On Error Resume Next
* * Set idx = Nothing
* * Set tdf = Nothing
* * Set db = Nothing
* * Exit Function

fErr:
* * errorLog "pkExists " & strTable
* * Resume fExit
End Function- Hide quoted text -

- Show quoted text -
changing the options to 'break on unhandled errors' instead of 'all
errors' solved the problem

Reply With Quote
  #7  
Old   
David W. Fenton
 
Posts: n/a

Default Re: converting to access2003 from access97 - 07-27-2010 , 07:01 PM



"Douglas J. Steele" <NOSPAM_djsteele (AT) NOSPAM_gmail (DOT) com> wrote in
news:i2l45k$qpj$1 (AT) news (DOT) eternal-september.org:

Quote:
Try replacing

CurrentDb.Execute strSql

with

CurrentDb.Execute strSql, dbFailOnError
But don't just do that without adding an error handler!

Or, Google for my SQLRun function that is an error-handled wrapper
around that command designed to be a dropin replacement for
DoCmd.RunSQL().

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.