Prev: Selling the boss on a "publish to the web" Access app?
Next: Can AlbertCo's tables be accessed?
From: Roger on 27 Jul 2010 19:27 On Jul 27, 7:55 am, Roger <lesperan...(a)natpro.com> wrote: > On Jul 27, 6:10 am, The Frog <mr.frog.to....(a)googlemail.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
From: David W. Fenton on 27 Jul 2010 20:01 "Douglas J. Steele" <NOSPAM_djsteele(a)NOSPAM_gmail.com> wrote in news:i2l45k$qpj$1(a)news.eternal-september.org: > 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/
First
|
Prev
|
Pages: 1 2 Prev: Selling the boss on a "publish to the web" Access app? Next: Can AlbertCo's tables be accessed? |