Access_Help
Registered User.
- Local time
- Today, 15:55
- Joined
- Feb 12, 2005
- Messages
- 136
Hi,
I am looking to make a custom messages for this code, If it imports successfully then output "Import Successful" else "Error in Source File".
New to coding, so any pre-written script to help would be appreciated.
I am looking to make a custom messages for this code, If it imports successfully then output "Import Successful" else "Error in Source File".
New to coding, so any pre-written script to help would be appreciated.
Code:
Private Sub cmdImportExcel_Click()
'the path to the excel workbook
Dim strExcelPath As String
strExcelPath = Environ("USERPROFILE") & "\My Documents\Students.xlsx"
'import data from excel
Call DoCmd.TransferSpreadsheet(acImport, _
acSpreadsheetTypeExcel8, "Students", strExcelPath, _
True, "A1:D11")
On Erro GoTo ErrorHanMsg1
MsgBox "Import Successful", , "Ok - 1"
Exit Sub
'This comes before End Sub or End Function Statement
ErrorHanMsg1:
MsgBox Err.Number & vbCr & Err.Description