lookforsmt
Registered User.
- Local time
- Today, 15:59
- Joined
- Dec 26, 2011
- Messages
- 672
HI!
i have the below code where i want to delete the table from db, but before that it should prompt me yes or no. but 3 conditions
1) If user press no, then the msgbox says file not deleted
2) If user press yes, then the msgbox says file deleted
Upto here the code works fine
i want the code to further check if there is no tables available in db then
3) if the user press yes, then the msgbox says table not available
Below is my code which i am not able to put the 3 condition
i have the below code where i want to delete the table from db, but before that it should prompt me yes or no. but 3 conditions
1) If user press no, then the msgbox says file not deleted
2) If user press yes, then the msgbox says file deleted
Upto here the code works fine
i want the code to further check if there is no tables available in db then
3) if the user press yes, then the msgbox says table not available
Below is my code which i am not able to put the 3 condition
Code:
Private Sub cmd_Delete_2_Click()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Const cstrPrompt As String = _
"Are you sure you want to delete the temp tables? Yes/No"
If MsgBox(cstrPrompt, vbQuestion + vbYesNo) = vbYes Then
Set db = CurrentDb
For Each tdf In db.TableDefs
If Not (tdf.Name Like "MSys*") And tdf.Name Like "[C-I]*" Then
DoCmd.DeleteObject acTable, tdf.Name
End If
Next
MsgBox (" Files deleted")
Else: MsgBox (" Files Not deleted")
End If
End Sub