Help with importing

  • Thread starter jln via AccessMonster.com
  • Start date
J

jln via AccessMonster.com

OK New problem I have it running now but it doesnt stop looping until the
table is filled. Did I miss something?

Private Sub Command0_Click()
Dim StrFolder As String
Dim strFileName As String
Dim strFullName As String
Dim dbf As Database
Const conFilter As String = "\*.xls"

Set dbf = CurrentDb
StrFolder = BrowseFolder("Select Folder For Imports")
If Len(StrFolder) = 0 Then
MsgBox "Import Canceled"
Exit Sub
End If

strFileName = Dir(StrFolder & conFilter)

Do While Len(strFileName) <> 0
strFullName = StrFolder & "\" & strFileName
DoCmd.TransferSpreadsheet acLink, , "PayoffMisMatch", strFullName, True
dbf.Execute ("qry_PayoffMismatch"), dbFailOnError
DoCmd.DeleteObject acTable, "PayoffMisMatch"
strFileName = Dir()
Loop


Set dbf = Nothing

End Sub
 
K

Klatuu

I don't know what you mean by "until the table is filled".

Try putting a breakpoint on this line:
strFileName = Dir()
and see what the value is after you execute it.
 
J

jln via AccessMonster.com

OK here is what i got one file i steped though the code and it is only going
though once. but in the table the data is being repated over and over.
I don't know what you mean by "until the table is filled".

Try putting a breakpoint on this line:
strFileName = Dir()
and see what the value is after you execute it.
OK New problem I have it running now but it doesnt stop looping until the
table is filled. Did I miss something?
[quoted text clipped - 27 lines]
 
J

jln via AccessMonster.com

OK got that fixed.


OK here is what i got one file i steped though the code and it is only going
though once. but in the table the data is being repated over and over.
I don't know what you mean by "until the table is filled".
[quoted text clipped - 7 lines]
 
K

Klatuu

That is pretty weird.
How many spreadsheets are in the folder you are importing from?
How are you running the code?

jln via AccessMonster.com said:
OK here is what i got one file i steped though the code and it is only going
though once. but in the table the data is being repated over and over.
I don't know what you mean by "until the table is filled".

Try putting a breakpoint on this line:
strFileName = Dir()
and see what the value is after you execute it.
OK New problem I have it running now but it doesnt stop looping until the
table is filled. Did I miss something?
[quoted text clipped - 27 lines]
 
J

jln via AccessMonster.com

It was the spreadsheet. I was only running one. Some how after i copyed the
spreadsheet the data got repeated in the spreadsheet thats why i was seeing
it in access.
That is pretty weird.
How many spreadsheets are in the folder you are importing from?
How are you running the code?
OK here is what i got one file i steped though the code and it is only going
though once. but in the table the data is being repated over and over.
[quoted text clipped - 10 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top