473,473 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help With Adox And Autonumber

10 New Member
Hi to everyone.
I am having a problem running the following code downloaded from the tips of Allen Browne:

Function DeleteAllAndResetAutoNum(strTable As String) As Boolean
Dim cat As New ADOX.Catalog
Dim tbl As ADOX.Table
Dim col As ADOX.Column
Dim strSql As String

'Delete all records.
strSql = "DELETE FROM [" & strTable & "];"
CurrentProject.Connection.Execute strSql

'Find and reset the AutoNum field.
cat.ActiveConnection = CurrentProject.Connection
Set tbl = cat.Tables(strTable)
For Each col In tbl.Columns
If col.Properties("Autoincrement") Then
col.Properties("Seed") = 1
DeleteAllAndResetAutoNum = True
End If
Next
End Function

this function has always worked perfectly. Now not anymore.
When it gets to the line "set tbl=cat.tables(strtable)" access crashes.
I use Office 2003. I tried reinstalling it, import the whole db into a new access file, apply the functions to different tables, empty or not. Still crash.
I then installed service pack two of office 2003 and no better.
The error information on crash are the following but to me they don't mean anything:

AppName: msaccess.exe AppVer: 11.0.6566.0 AppStamp:42cdb33e
ModName: msjet40.dll ModVer: 4.0.8618.0 ModStamp:403430ac
fDebug: 0 Offset: 00046ddc

The reference to the adox library is "Microsoft ADO Ext. 2.8 for DDL and security" and it points to the, I guess, correct Msadox.dll. The version of that dll is 2.81.1128.0 which i think is the latest one.
Please if anyone can help because I am now out of resources.
Thank you,
Jacopo
Jul 24 '07 #1
6 3682
ADezii
8,834 Recognized Expert Expert
Hi to everyone.
I am having a problem running the following code downloaded from the tips of Allen Browne:

Function DeleteAllAndResetAutoNum(strTable As String) As Boolean
Dim cat As New ADOX.Catalog
Dim tbl As ADOX.Table
Dim col As ADOX.Column
Dim strSql As String

'Delete all records.
strSql = "DELETE FROM [" & strTable & "];"
CurrentProject.Connection.Execute strSql

'Find and reset the AutoNum field.
cat.ActiveConnection = CurrentProject.Connection
Set tbl = cat.Tables(strTable)
For Each col In tbl.Columns
If col.Properties("Autoincrement") Then
col.Properties("Seed") = 1
DeleteAllAndResetAutoNum = True
End If
Next
End Function

this function has always worked perfectly. Now not anymore.
When it gets to the line "set tbl=cat.tables(strtable)" access crashes.
I use Office 2003. I tried reinstalling it, import the whole db into a new access file, apply the functions to different tables, empty or not. Still crash.
I then installed service pack two of office 2003 and no better.
The error information on crash are the following but to me they don't mean anything:

AppName: msaccess.exe AppVer: 11.0.6566.0 AppStamp:42cdb33e
ModName: msjet40.dll ModVer: 4.0.8618.0 ModStamp:403430ac
fDebug: 0 Offset: 00046ddc

The reference to the adox library is "Microsoft ADO Ext. 2.8 for DDL and security" and it points to the, I guess, correct Msadox.dll. The version of that dll is 2.81.1128.0 which i think is the latest one.
Please if anyone can help because I am now out of resources.
Thank you,
Jacopo
Everything looks fine - the only logical explanation, in my mind, would be a corrupt .dll, specifically the one which provides the ADOX functionality (Msadox.dll).
Jul 25 '07 #2
Jacopo
10 New Member
Dear Adezii,
thank you for the reply. I concentrated on the dll and turns out that the version 2.81.1128.00 has been updated from version 1117 with an automatic update of windows through the security update reference KB92779. I uninstalled the security update and the msadox.dll turned back to version 1117 but the problem was still there. So i manually downloaded and installed again the security update changing again the dll to version 1128, but again access crashes.
Any idea? Thank you for any help.
Jacopo
Jul 25 '07 #3
ADezii
8,834 Recognized Expert Expert
Dear Adezii,
thank you for the reply. I concentrated on the dll and turns out that the version 2.81.1128.00 has been updated from version 1117 with an automatic update of windows through the security update reference KB92779. I uninstalled the security update and the msadox.dll turned back to version 1117 but the problem was still there. So i manually downloaded and installed again the security update changing again the dll to version 1128, but again access crashes.
Any idea? Thank you for any help.
Jacopo
Everything else seems sound - when you type ADOX. does the Intellisense feature work, namely the Properties, Methods, etc. of ADOX automatically appear in a Drop Down.
Jul 25 '07 #4
Jacopo
10 New Member
Again thank you for the reply.
And yes the intellisense works. I thought about it so I retyped all the declarations. I also tried to move the function to a brand new module thinking that maybe that specific module could be corrupted (never heard about it but when you are desperate...).
Now I have reinstalled again Office, this time the US version. It is a student version but complete. I shouldn't use it to develop commercial products but hell I paid good money to Microsoft for the italian one.
Anyway the problem is still there, even if I tried to delete the reference and point again to it, and also changed the order of the references (sometimes it affects the behavior).
Quite honestly I am thinking to bypass ADOX considering that the same can be done without it. It might be a problem in the future if I will have to modify the database on site when the customer already has data in it, because there ADOX comes handy, but I will think about it when it comes.
Yet, even if I don't want to bug you too much, I would be grateful if you come up with some other ideas.
Thank you for your time Adezii.
Jacopo
Jul 25 '07 #5
ADezii
8,834 Recognized Expert Expert
Again thank you for the reply.
And yes the intellisense works. I thought about it so I retyped all the declarations. I also tried to move the function to a brand new module thinking that maybe that specific module could be corrupted (never heard about it but when you are desperate...).
Now I have reinstalled again Office, this time the US version. It is a student version but complete. I shouldn't use it to develop commercial products but hell I paid good money to Microsoft for the italian one.
Anyway the problem is still there, even if I tried to delete the reference and point again to it, and also changed the order of the references (sometimes it affects the behavior).
Quite honestly I am thinking to bypass ADOX considering that the same can be done without it. It might be a problem in the future if I will have to modify the database on site when the customer already has data in it, because there ADOX comes handy, but I will think about it when it comes.
Yet, even if I don't want to bug you too much, I would be grateful if you come up with some other ideas.
Thank you for your time Adezii.
Jacopo
I've looked at this from every conceivable angle, and still I come up with a big ZERO. Just one more, last ditch effort. Run the code directly, outside of the Function Procedure, so no Argument (Table Name) is being passed to the Function, so the Object Variable assignment is set directly to a Table Name. Something this drastic as a System Crash on this specific line may indicate something similar to a memory overwrite where strName is overwriting an existing and occupied memory space. I know it sounds crazy, but please just try it. Let me know how you make out.
Expand|Select|Wrap|Line Numbers
  1. Dim cat As New ADOX.Catalog
  2. Dim tbl As ADOX.Table
  3. Dim col As ADOX.Column
  4. Dim strSql As String
  5.  
  6. 'Delete all records.
  7. strSql = "DELETE FROM Table1;"
  8. CurrentProject.Connection.Execute strSql
  9.  
  10. 'Find and reset the AutoNum field.
  11. cat.ActiveConnection = CurrentProject.Connection
  12.  
  13. Set tbl = cat.Tables("Table1")
  14.  
  15. For Each col In tbl.Columns
  16.   If col.Properties("Autoincrement") Then
  17.     col.Properties("Seed") = 1
  18.     DeleteAllAndResetAutoNum = True
  19.   End If
  20. Next
Jul 25 '07 #6
Jacopo
10 New Member
Dear Adezii,
I tried what you said, but no luck. Sorry I gave you headache for this. You have been very very kind in trying and helping me.
The development of my program is still far from being done so I wouldn't surprise that before the end, for some odd reasons it goes back working. By the way, I have a back up (though too behind in the development to be used) where it works, so the dll are fine. I tried cleaning that file and import all from the new one into it but again it crashes. I throw the towel at the moment.
Again ty for all your efforts, but i don't want you to get crazy over it.
Jacopo
Jul 26 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Null Reference | last post by:
Anybody here who can explain or point me to a link ? I wish to create a blank MS Access DB file programmatically using C# . Thanks, nfs
1
by: Randy | last post by:
Hello, I'm not sure if this is the correct place to post this, but I've got a C# app in which I've added a reference to the ADOX (Interop.ADOX) library and I'm using... ADOX.CatalogClass cat =...
5
by: Wayne Wengert | last post by:
I am getting an error that "object no longer valid" at the point indicated in the code below - I am trying to build a table in an Access 2000 database using ADOX. Any thoughts on what might cause...
3
by: gaffar | last post by:
Sir, Using ADOX I am developing an application in vb.net and the backend database is ms-access. i have created ms-access databse and tables and assigned primary keys to the tables through the...
1
by: sunlight_sg | last post by:
Hello, i am using ADOX + VB .NET to create a Access Database programmatically. I plan to set some properties of the column such primary key. The code is as follows: Dim cat As ADOX.Catalog...
1
by: Hexman | last post by:
I'm creating a new Access table using ADOX. I can add columns and indexes, but I'm baffled on how to change field properties. Can someone give me a hand? Want to change properties such as:...
8
by: T Clancey | last post by:
Hi. I have an application that needs to update a database, as I'm using vb net and an access database I have to do this using ADOX. I don't think there is another way. I have found all sorts...
3
by: Miro | last post by:
Something weird I have run into when trying to add a boolean field to an Access table by code. -Just wondering if anyone else has run into this. ( vb.net 2005 express ) If I add any other...
0
parshupooja
by: parshupooja | last post by:
Hey all, I have Arraylist where I have stored names of Tables.I have two datasources one is SQL and one is Access, they have equal number of tabels. I am trying to find Access databse column and...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.