I've added the following code to one of my access forms:
Dim tnm As String
'Get the table name
tnm = [Forms]![Form1]!Text0.Value
If Not CurrentDb(tnm) Then
MsgBox "This table already exists in the Database."
DoCmd.RunSQL "DELETE * FROM " & [Forms]![Form1]![Text0] & ""
DoCmd.RunSQL "ALTER TABLE " & [Forms]![Form1]![Text0] & " DROP COLUMN MakeName"
Else
End If
The form was working just fine before and this statement is running but then as it is about to finish i get an applications error that shuts down access. Does anyone have any ideas on what would be causing this if i just added this one piece of code.
I want to check to see if the table that I am about to create already existed and if it did delete it before I create the new one.
Dim tnm As String
'Get the table name
tnm = [Forms]![Form1]!Text0.Value
If Not CurrentDb(tnm) Then
MsgBox "This table already exists in the Database."
DoCmd.RunSQL "DELETE * FROM " & [Forms]![Form1]![Text0] & ""
DoCmd.RunSQL "ALTER TABLE " & [Forms]![Form1]![Text0] & " DROP COLUMN MakeName"
Else
End If
The form was working just fine before and this statement is running but then as it is about to finish i get an applications error that shuts down access. Does anyone have any ideas on what would be causing this if i just added this one piece of code.
I want to check to see if the table that I am about to create already existed and if it did delete it before I create the new one.