Home   |   Asp.Net 2.0   |   .Net Framework 2.0   |   IIS 6.0   |   Sql Server 2005   |   Visual Basic 2005   |   c# 2005   |   VS 2005   |   Visual Source Safe 2005

MS Dynamics CRM 3.0

SharePoint Portal Server 2003
SharePoint Server 2007
Dynamics NAV
Dynamics CRM
SharePoint Designer 2007
SharePoint Portal Server 2001
Windows SharePoint Services
Windows SharePoint Services 3.0
Project Server 2003
Project Server 2007
Dynamics – Point of Sale
Dynamics AX
Dynamics GP
Dynamics Retail Management System (RMS)
Dynamics SL
SQL Server 2000
Visual Basic .NET 2003
Visual C# .NET 2003
Visual C++ .NET 2003
Visual C++ 2005
Visual SourceSafe 6.0
Windows Server 2003
Windows Server 2003
Outlook 2003
ADO.NET 1.1
ASP.NET 1.0
Visual Studio Team Foundation Server
Visual Studio 2005 Team Edition
Windows Internet Explorer 7
BizTalk Server 2000
BizTalk Server 2002
BizTalk Server 2004
BizTalk Server 2006
Visual Studio 6.0
Access 2000
Access 2002
Access 2003
Access 2007
Access 97
Collaboration Data Objects 2.0
Commerce Server 2002
Content Management Server 2001
Commerce Server 2007
Content Management Server 2002
Data Access Components 2.7
Data Access Components 2.8
DirectX 9.0b
Office Small Business Accounting 2006
Accounting 2007
ActiveSync 4.1
Class Server 2.0
Groove 2007
Windows Vista
Outlook 2007
OneNote 2003
OneNote 2007
Office X for Mac
Zune software
Zune Live
Zoo Tycoon 2
Flight Simulator 2002
Dungeon Siege II

Cervo Technologies
The Right Source to Outsource

Oracle Database FAQS

Sharepoint Portal Server KB

Outlook 2007 Knowledge Base Articles

Access 97 Knowledge Base Articles

Advanced: Requires expert coding, interoperability, and multiuser skills. When you add a record to an SQL table by using Visual Basic for Applications, if the table's unique index field has a default value, and you do not assign a value to that...


Advanced: Requires expert coding, interoperability, and multiuser skills.

When you add a record to an SQL table by using Visual Basic for Applications, if the table's unique index field has a default value, and you do not assign a value to that field, the new record appears deleted until you reopen the SQL table. If you try to obtain a value from the new record, you receive the following error message:
Run-time error '3167'
Record is deleted.

RESOLUTION

When you open the SQL table by using Visual Basic code, include the dbSeeChanges option, as in the following example:
   Set rs = db.OpenRecordset("TestTable", dbOpenDynaset, dbSeeChanges)
				

The dbSeeChanges option ensures that any newly added records that contain a default value in the unique index field are available in the current recordset.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior


1.Create a module and type the following line in the Declarations section if it is not already there:
      Option Explicit
						
2.Type the following procedure:
      Function TestSQLData()

         Dim db As Database, rs As Recordset
         Dim idx, td
         Dim cmd As String

         ' Delete TestTable if it exists on the SQL server.
         Set db = OpenDatabase("", False, False,ODBC;dsn=<datasource>; _
            database=<database>;uid=<user id>;pwd=<password>")
         cmd = "if exists (select * from sysobjects where _
            id = object_id('dbo.TestTable'))"
         cmd = cmd & " drop table TestTable"
         db.Execute cmd, dbSQLPassThrough

         ' Create TestTable with one field on SQL server.
         Set td = db.CreateTableDef("TestTable")
         td.Fields.Append td.CreateField("Int", dbInteger)
         td.Fields.Append td.CreateField("String", dbText, 50)
         db.TableDefs.Append td

         Set idx = td.CreateIndex("MyIdx")
         idx.Unique = True
         idx.Fields.Append idx.CreateField("Int")
         td.Indexes.Append idx

         cmd = "create Default TestDef3 as 100"
         db.Execute cmd, dbSQLPassThrough

         cmd = "sp_bindefault TestDef3, 'TestTable.Int'"
         db.Execute cmd, dbSQLPassThrough

         ' Open table, add a record, and then obtain values.
         Set rs = db.OpenRecordset("TestTable")
         rs.AddNew
         rs!String = "Trial"
         rs.Update

         Debug.Print "RecordCount = " & rs.RecordCount
         rs.MoveFirst
         Debug.Print "String is " & rs("String")
         Debug.Print "Int is " & rs("Int")
         rs.Close

      End Function
						
3.To test this function, type the following line in the Debug window, and then press ENTER:

? TestSQLData()

Note that run-time error '3167' occurs.

REFERENCES

For more information about the OpenRecordset method, search the Help Index for "OpenRecordset," and then "OpenRecordset method," or ask the Microsoft Access 97 Office Assistant.


APPLIES TO
Microsoft Access 95 Standard Edition
Microsoft Access 97 Standard Edition

Keywords: 
kberrmsg kbprb kbusage KB135379

Copyright © 2004 - 2007 Gridview.org, Inc. All rights reserved. Powered by Smart Web Content Management System