G
Guest
I have a "form" with a command button that deletes a table and relinks that
table from SQL.(Done to change from one table to a different table but has
the same format, just a different set of records) Reads as follows
Private Sub cmdAttachTable_Click()
If MsgBos ("Attach table " & Forms!frmAttachTable!Attach & "?") Then
DoCmd.DeleteObject acTable, "Campaign"
Docmd.TransferDatabase acLink, "ODBC", ............
DoCmd.Close
End If
End Sub
Now sometimes (too often for me) I lose the link to the table and I have to
go in and manually link back to the table and rename it. What I would like
to do is to put a EXISTS and/or IF ELSE statement like follows
Private Sub cmdAttachTable_Click()
If MsgBos ("Attach table " & Forms!frmAttachTable!Attach & "?") Then
If table.EXISTS ("Campaign") = True THEN
DoCmd.DeleteObject acTable, "Campaign"
Docmd.TransferDatabase acLink, "ODBC", ............
DoCmd.Close
Else
Docmd.TransferDatabase acLink, "ODBC", ............
DoCmd.Close
End If
End If
End Sub
For some reason I get a error message
Run-time error '424':
Object required
Any help or suggestions?
table from SQL.(Done to change from one table to a different table but has
the same format, just a different set of records) Reads as follows
Private Sub cmdAttachTable_Click()
If MsgBos ("Attach table " & Forms!frmAttachTable!Attach & "?") Then
DoCmd.DeleteObject acTable, "Campaign"
Docmd.TransferDatabase acLink, "ODBC", ............
DoCmd.Close
End If
End Sub
Now sometimes (too often for me) I lose the link to the table and I have to
go in and manually link back to the table and rename it. What I would like
to do is to put a EXISTS and/or IF ELSE statement like follows
Private Sub cmdAttachTable_Click()
If MsgBos ("Attach table " & Forms!frmAttachTable!Attach & "?") Then
If table.EXISTS ("Campaign") = True THEN
DoCmd.DeleteObject acTable, "Campaign"
Docmd.TransferDatabase acLink, "ODBC", ............
DoCmd.Close
Else
Docmd.TransferDatabase acLink, "ODBC", ............
DoCmd.Close
End If
End If
End Sub
For some reason I get a error message
Run-time error '424':
Object required
Any help or suggestions?