jdawg_1989
Registered User.
- Local time
- Today, 20:59
- Joined
- Apr 8, 2011
- Messages
- 21
I currently have the following VBA Code linked to a button on a form.
The Code basically deletes contents of a table already in the database and imports a .CSV file to the table it's wiped. The code then goes on to update another table with todays date which I link to, to say when the DB was last updated. A message box then pops up to tell me the DB was updated successfully.
The .CSV file is located on a server which not all users have access to, so I'd like a popup message something like "Connection to Server failed, would you like to retry?" If Yes I want it to retry and If No I want it to stop running the remainder of the code.
I've been playing around for hourUs with no results. Any ideas are welcome, thanks in advance.
Code:
Private Sub UpdateDBbutton_Click()
DoCmd.Echo False, "Importing latest data to DB, please be patient..."
DoCmd.Hourglass True 'turn on the hour glass
' The following Code Deletes all records from Port Usage Table
DoCmd.SetWarnings (False)
Dim strquery As String
strquery = "DELETE [Port Usage].Locaity, [Port Usage].location, [Port Usage].Id, [Port Usage]
FROM [Port Usage];"
DoCmd.RunSQL strquery
DoCmd.SetWarnings (True)
' The following Code imports CSV file to Port Usage Table
DoCmd.TransferText acImportDelim, , "Port Usage", _
"\\sever\folder\Port Usage.csv", -1
' The following Code updates the Last Update Date Table with the latest time and date
DoCmd.SetWarnings (False)
Dim strquery2 As String
strquery2 = "UPDATE [Last Update Date] SET [Last Update Date].[Last Update Date] = Now();"
DoCmd.RunSQL strquery2
DoCmd.SetWarnings (True)
DoCmd.Echo True, ""
DoCmd.Hourglass False 'turn off the hour glass
MsgBox "Database updated successfully! :)"
End Sub
The .CSV file is located on a server which not all users have access to, so I'd like a popup message something like "Connection to Server failed, would you like to retry?" If Yes I want it to retry and If No I want it to stop running the remainder of the code.
I've been playing around for hourUs with no results. Any ideas are welcome, thanks in advance.
Last edited: