Private Sub Form_Load()
Call Copy
End Sub
Sub Copy()
If DoesTblExist("LoadTableFinal") Then
CurrentDb.Execute "DROP TABLE LoadTableFinal", dbFailOnError
Me.Refresh
CurrentDb.Execute "SELECT [dbo_Load Table].* INTO LoadTableFinal FROM [dbo_Load Table];"
Me.Requery
Else
CurrentDb.Execute "SELECT [dbo_Load Table].* INTO LoadTableFinal FROM [dbo_Load Table];"
Me.Requery
End If
End Sub
Function DoesTblExist(sTableName As String) As Boolean
Dim db As DAO.Database
Dim tdf As TableDef
On Error GoTo Error_Handler
'Initialize our variable
DoesTblExist = False
Set db = CurrentDb()
Set tdf = db.TableDefs(sTableName)
DoesTblExist = True 'If we made it to here without triggering an error
'the table exists
Error_Handler_Exit:
On Error Resume Next
Set tdf = Nothing
Set db = Nothing
Exit Function
Error_Handler:
If Err.Number = 3265 Then
'If we are here it is because the table could not be found
Else
MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf & "Error Number: " & _
Err.Number & vbCrLf & "Error Source: DoesTblExist" & vbCrLf & "Error Description: " & _
Err.Description, vbCritical, "An Error has Occured!"
End If
Resume Error_Handler_Exit
End Function
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE