Need Code to download file

Kronos

Registered User.
Local time
Today, 10:01
Joined
Jul 18, 2005
Messages
13
So here is the deal.
I am creating a database that will need to import about 5,000 csv files. I got that part down, the problem is where these files are located.
I'm downloading them off an internet server.
What I have done so fare is attached the link to a command button, but I must click the button 5,000 times for this process to work, basically every time I click the button, it changes the "hyperlinkaddress" property to the next address.
Is there a way in VB code to bypass the command button, basically what I’m looking to do, is click a button once, and have the files downloaded to a folder on my computer, then when that is complete, click another button and import each file into access, then kill them, I got everything done, except for the line of code that would say “hay download this file” Any help would be great. Thanks.
 
How about showing some codes so that we know exactly where to put the "hay download this file" code at?

Will it always be 5000?
 
I'm sorry about the delay, I had a very close person problem, and well there was no other thought in my head except that problem....so her is the code, this works, however.....well I would like it to click go and hae this run in a loop untill all the files are fully imported, I know how to do everything except one thing, and that is to trigger getting the link to load without clicking on a button and having the address attached to it. bassicaly i'm lookin for a silver bullet that would run and say go to this link, the webpage opens and you click save, I have the program do everything it needs to do and then go to the next record to download.


Private Sub Command_Button_Click()
If Me![List4] = "" Then
MsgBox "You did not select a Symbol you silly person in your Pink Hairless Monkey Suit!.", vbOKOnly
Else
If Me![Command Button].Caption = "Done" Then
MsgBox "File has already been Imported." & vbNewLine & _
"Please Select another Symbol.", vbOKOnly
Else
Dim stLinkCriteria As String
Dim stLinkCriteriaPart1 As String
Dim stLinkCriteriaPart2 As String
Dim StlinkCriteriaPart3 As String
stLinkCriteriaPart1 = "http://data.moneycentral.msn.com/scripts/chrtsrv.dll?Symbol="
stLinkCriteriaPart2 = DLookup("[Symbol]", "Links", "[Link ID Tag]=" & Me![Link ID Tag])
StlinkCriteriaPart3 = "&FileDownload=&C1=1&C2=&C3=10&C4=3&C5=2&C6=2006&C7=2&C8=2006&C9=2&CE=0&CF=0&D3=0&D4=1&D5=0"
stLinkCriteria = stLinkCriteriaPart1 + stLinkCriteriaPart2 + StlinkCriteriaPart3
If Me![Command Button].Caption = "Download File" Then
Me![Command Button].hyperlinkaddress = stLinkCriteria
Me![Downloaded] = -1
Me![Command Button].Caption = "Import File"
Me.Refresh
Else
If Me![Imported] = 0 Then
Dim RecordAt As Integer
Dim RecordCount As Integer
Dim FilePath As String
FilePath = DLookup("[Path]", "File Path", "[ID Tag]=1")
DoCmd.CopyObject , "TempCopy", acTable, "Temp"
Me![Command Button].hyperlinkaddress = ""
DoCmd.TransferText acImportDelim, , "TempCopy", FilePath & stLinkCriteriaPart2 & ".csv"
DoCmd.OpenForm "Delete TempCopy Blank Records", acNormal, , , , acWindowNormal
Kill FilePath & stLinkCriteriaPart2 & ".csv"
RecordAt = DMin("[F7]", "TempCopy")
RecordCount = DMax("[F7]", "TempCopy")
DoCmd.SetWarnings False
For RecordAt = RecordAt To (RecordAt + 5)
[Forms]![Delete TempCopy Blank Records].SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Next
DoCmd.DeleteObject acTable, stLinkCriteriaPart2 & "_ImportErrors"
DoCmd.SetWarnings True
DoCmd.Close acForm, "Delete TempCopy Blank Records", acSaveYes
For RecordAt = RecordAt To RecordCount
DoCmd.OpenForm "TempCopy to Stock Data", acNormal, , , acFormAdd, acHidden
[Forms]![TempCopy to Stock Data]![Date] = DLookup("[F1]", "TempCopy", "[F7]=" & RecordAt)
[Forms]![TempCopy to Stock Data]![Open] = DLookup("[F2]", "TempCopy", "[F7]=" & RecordAt)
[Forms]![TempCopy to Stock Data]![High] = DLookup("[F3]", "TempCopy", "[F7]=" & RecordAt)
[Forms]![TempCopy to Stock Data]![Low] = DLookup("[F4]", "TempCopy", "[F7]=" & RecordAt)
[Forms]![TempCopy to Stock Data]![Close] = DLookup("[F5]", "TempCopy", "[F7]=" & RecordAt)
[Forms]![TempCopy to Stock Data]![Volume] = DLookup("[F6]", "TempCopy", "[F7]=" & RecordAt)
[Forms]![TempCopy to Stock Data]![Link ID Tag] = Me![Link ID Tag]
DoCmd.Close acForm, "TempCopy to Stock Data", acSaveYes
Next
Me![Imported] = -1
DoCmd.DeleteObject acTable, "TempCopy"
Me![Command Button].Caption = "Done"
DoCmd.Close acForm, "Add Record", acSaveYes
DoCmd.OpenForm "Add Record", acNormal, , , , acWindowNormal
MsgBox "Import Completed.", vbOKOnly, "Complete"
Else
MsgBox "File is already imported, select another.", vbOKOnly
End If
End If
End If
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom