473,467 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help to make Mdb code work on accdb database

9 New Member
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub Form_Load()
  4.     For i = 0 To CurrentDb.TableDefs.Count - 1
  5.         If InStr(CurrentDb.TableDefs(i).Name, "MSys") = 0 Then
  6.             cmbTable.AddItem (CurrentDb.TableDefs(i).Name)
  7.         End If
  8.      Next
  9. End Sub
  10.  
  11. Private Sub xmlBtn_Click()
  12. On Error GoTo Err_xmlBtn_Click
  13.     Create_XML (cmbTable.Column(0))
  14.  
  15. Exit_xmlBtn_Click:
  16.     Exit Sub
  17.  
  18. Err_xmlBtn_Click:
  19.     MsgBox Err.Description
  20.     Resume Exit_xmlBtn_Click
  21.  
  22. End Sub
  23. Private Sub Create_XML(tableName)
  24.  
  25.     Dim Rs As Recordset
  26.  
  27.     Set Rs = CurrentDb.OpenRecordset("SELECT * FROM " & tableName, dbOpenSnapshot)
  28.     If Rs.RecordCount > 0 Then
  29.         Rs.MoveFirst
  30.  
  31.     Dim objDom As MSXML2.DOMDocument60
  32.     Dim objRootElem As IXMLDOMElement
  33.     Dim objMemberElem As IXMLDOMElement
  34.     Dim objMemberName As IXMLDOMElement
  35.  
  36.  
  37.  
  38.  
  39.  
  40.     Set objDom = New MSXML2.DOMDocument60
  41.  
  42.     Set objRootElem = objDom.createElement(tableName)
  43.     objDom.appendChild objRootElem
  44.  
  45.     Do While Not Rs.EOF
  46.         Set objMemberElem = objDom.createElement("Claim")
  47.         objRootElem.appendChild objMemberElem
  48.  
  49.  
  50.         For i = 0 To Rs.Fields.Count - 1
  51.             Set objMemberName = objDom.createElement(Rs.Fields(i).Name)
  52.             objMemberElem.appendChild objMemberName
  53.             objMemberName.Text = Rs.Fields(i).Value
  54.             objMemberElem.appendChild objDom.createTextNode(vbCrLf)
  55.         Next
  56.     Rs.MoveNext
  57.     Loop
  58.  
  59.     Rs.Close
  60.    ' Saves XML data to disk.
  61.    objDom.Save (CurrentProject.Path & "\" & tableName & ".xml")
  62.    MsgBox "Table exported sucessfully."
  63.    End If
  64. End Sub
  65.  
Please assist me to make this code work in access 2013 its giving me error user- defined type not defined. its from mdb, and also to be able to add related tables as child to main table.

Regards
Mar 11 '19 #1
3 721
twinnyfo
3,653 Recognized Expert Moderator Specialist
O bake get,

Your code should work in newer versions of 2013. However, if you are receiving a User-defined error, it is mostl likely that you have not declared a reference in your VBA: Tools | References.

I can’t tell you which reference you need because you haven’t told us which line of your code produces the error (hint: that’s just a good practice on this forum, to tell us which line produces an error). It’s difficult for us to move beyond without that information.

As a side note, the second line of all of your Modules should be Option Explicit, which forces you to declare all your variables. If this line was present, and you tried compiling/debugging your code, the error-producing line would be highlighted for you.
Mar 11 '19 #2
Obakeng1168
9 New Member
Thank you for your prompt reply, This is the line that is highlighted as error

Dim objDom As MSXML2.DOMDocument60

Regards
Mar 11 '19 #3
twinnyfo
3,653 Recognized Expert Moderator Specialist
Yes - this just confirms my suspicion that you are missing a reference. I can't tell you which reference you need because I don't use XML. But, that same reference will be in your old DB, based upon my description in the previous post. Just make sure you have the same references in both DBs.
Mar 11 '19 #4

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

Similar topics

6
by: Chris Krasnichuk | last post by:
Hello every one, Does anyone know how to make php work on your computer? please reply I need help Chris
0
by: Rob Cheshire | last post by:
Hi to all, I need some help deciding on the best database system for our specific application. OPTIONAL INFO: We currently have 2 separate projects that need to be updated from dos-based dBase. ...
4
by: Digital Fart | last post by:
howto make a connection to database available in my classes. What is the best practice when i want to write classes that need a connection to the database? Do i make a conn variable in my...
3
by: Marek | last post by:
Hello gurus! I wrote a code in VBS, that will check, that current user is in one from three groups. But i don't know how asimilate it with asp.net. This page will be a bridge between 2 - main...
5
by: Gustavo De la Espriella | last post by:
I'm refrasing a question I posted earlier because I didn't explain myself. I need an efficient way to make an especific comercial application able to use whatever database the client prefers a...
2
by: RC | last post by:
By default PHP always supports MySQL. But all our database servers are PostgreSQL or Informix. Order for me get PHP supports other than MySQL. I need download PHP source codes and compiled it...
48
by: Nathan Sokalski | last post by:
Ever since I found out that they didn't give us a way to install both IE6 and IE7 on the same machine, I have been more frustrated and annoyed with Microsoft than I ever have been with any company...
3
by: Robert | last post by:
I understand that new features would not be available but is there any way I could open an accdb database in Access 2003? Robert
1
by: FlashT | last post by:
Hello, I got a script: http://www.mattkruse.com/javascript/autocomplete/index.html It works fine on IE and Opera, but does not on FF. It does something on FF, but not what it should do (check...
1
by: rayfalcon | last post by:
what kind of coding is this ? and how do i make it work as a banner on my myspace page so that people can click it to goto my site thats listed on the banner ? the banner code is for a site called...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
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
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.