Go Back   Access World Forums > Apps and Windows > VB.NET

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 11-21-2010, 07:20 PM   #1
desmond
Newly Registered User
 
Join Date: Dec 2009
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
desmond is on a distinguished road
Erratic results when updating properties to more than 1 table

I am successfully updating the properties of an access database column, but if I try to update the same properties of another table immediately after, I get erratic results.

Sometimes the result says 'Record deleted'; sometimes the result says 'cannot append. an object with that name already exists in the collection'; sometimes the result says 'object invalid or no longer set'.

This only happens to the second table, the first table is successfully updated.

Here is my code:

Dim dbe As Microsoft.Office.Interop.Access.Dao.DBEngine
Dim dbs As Microsoft.Office.Interop.Access.Dao.Database
Dim fld As dao.Field
Dim prp As dao.Property
Dim prp As dao.Property

'update column to checkbox

dbe = New Microsoft.Office.Interop.Access.Dao.DBEngine()
dbs = dbe.OpenDatabase("C:\MyDB.accdb")
fld = dbs.TableDefs("DBTest").Fields("TestFlag")
prp = fld.CreateProperty("DisplayControl", dbInteger, 106)

Try
fld.Properties.Append(prp)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information)
End Try

dbs.Close()

'update table 2 column to checkbox

dbe = New Microsoft.Office.Interop.Access.Dao.DBEngine()
dbs = dbe.OpenDatabase("C:\MyDB.accdb")
fld = dbs.TableDefs("DBTest2").Fields("TestFlag")
prp = fld.CreateProperty("DisplayControl", dbInteger, 106)

Try
fld.Properties.Append(prp)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information)
End Try

dbs.Close()

Has this got something to do with the column in table2 having the same name? I've scoured the net for answers to no avail.

Hoping someone can offer some suggestions.

desmond is offline   Reply With Quote
Reply

Tags
access , append , erratic , properties , vb.net

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating date in table produces bizarre results fredalina Modules & VBA 4 01-09-2009 10:55 AM
Erratic results from code hartster Modules & VBA 4 03-16-2008 06:44 PM
Erratic query behaviour? matt beamish Queries 3 06-19-2007 04:50 AM
Table column name properties/Combo Box head properties Z34Lee General 5 12-08-2006 09:52 AM
Erratic Code George Too Modules & VBA 1 05-20-2003 05:23 AM




All times are GMT -8. The time now is 06:08 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World