Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IMPORT XML

Status
Not open for further replies.

tar28un

Technical User
Nov 29, 2005
58
0
0
GB
Hi there,

I am trying to import nearly 150 xml from my folder to an access database.

For that I have written a code to import the files in . Now as the files names contains no. and they are next to each other. Now suppose if the file names are 1, 8, 45, 78 and 90. I am running a counter from 1 to 100 to pick up all the files in between. But as soon as it found a file I m asking it do some other additions and deletions. It works fine but it runs all the commands for all the file no. whereas I want it to run them for files which are found.

Is there any is found() or if found() functin in VB, so that I check first that if a file is found then a set comman would run otherwise not.

Plz help, very urgent.

Thanks
 
Hmm, maybe you can use something like:
Code:
If File.Exists Then
   ~your code
End If
 
tar28un,
It would be helpful to see what method your using to open the files that way we could provide an answer relevent to the method your using.

CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Have a look at the Dir function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi there,

I am using the follwing code:

For i = 2000 To 4000
On Error Resume Next
For j = 1 To 50
If j < 10 Then
s = "00" & j & ""
Else
s = "0" & j & ""
End If
ImportXML "C:\Year 4 Results 850" & i & "new" & s & ".xml", acStructureAndData
Next
If i > 2000 Then
str = "insert into result select result1.* from result1"
DoCmd.RunSQL str
sql1 = "drop table result1"
DoCmd.RunSQL sql1
sql1 = ""
End If
sql1 = "drop table aspect"
DoCmd.RunSQL sql1
sql1 = ""
sql1 = "drop table grade"
DoCmd.RunSQL sql1
sql1 = ""
sql1 = "drop table gradeset"
DoCmd.RunSQL sql1
sql1 = ""
sql1 = "drop table gradesethistory"
DoCmd.RunSQL sql1
sql1 = ""
sql1 = "drop table importerrors"
DoCmd.RunSQL sql1
sql1 = ""
sql1 = "drop table markset"
DoCmd.RunSQL sql1
sql1 = ""
sql1 = "drop table resultfile"
DoCmd.RunSQL sql1
sql1 = ""
'sql1 = "rename table result to result' & i & '"
'DoCmd.RunSQL sql1
Next
*******************

In the above before the Import xml statement I want to check whether that actually exists or not If yes then it should import it and run the statements that follows and if not that the program shall continue with the start again.

Many thanks
 
A starting point:
myFile = "C:\Year 4 Results 850" & i & "new" & s & ".xml"
If Dir(myFile) = "" Then
MsgBox myFile " NOT FOUND"
Else
ImportXML myFile, acStructureAndData
...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Many thanks

It is working. I have one more question if you can help with. When I import any file manually , I have one option to choose to say to append the data in the existing file. How I can use that with importxml command.

thanks
 
ImportXML myFile, acAppendData

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top