Yes/No Action not working (1 Viewer)

molsen

Registered User.
Local time
Yesterday, 21:33
Joined
Sep 13, 2012
Messages
50
Hi All

I'm a relative newbie to the world of VB, and I've written the following code, to delete the contents of multiple tables. The trouble is, if the user says No to the Y/N message, it still deletes the contents. What is missing so that it abandons the process if N is chosen, and another message comes up saying something like "No Records have been deleted"?

Many thanks

VB Newbie Mark

'------------------------------------------------------------
' mcro_delete_all_fund_tables
'
'------------------------------------------------------------
Function mcro_delete_all_fund_tables()
On Error GoTo mcro_delete_all_fund_tables_Err
DoCmd.SetWarnings False
DeleteYesNo
DoCmd.OpenQuery "qry_delete balanced equity dealer", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete balanced equity pulse", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete balanced equity SWFAL", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete CHIG Dealer", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete CHIG Pulse", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete CHIG SWFAL", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete esk dealer", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete deep value pulse", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete esk pulse", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete tenax dealer", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete esk SWFAl", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete tenax pulse", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete uk managed growth", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete tenax SWFAL", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete uk managed growth pulse", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete worldwide dealer", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete worldwide pulse", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete uk managed growth SWFAL", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete deep value SWFAL", acViewNormal, acEdit
DoCmd.OpenQuery "qry_delete worldwide SWFAL", acViewNormal, acEdit
Beep
MsgBox "All Records have now been deleted", vbInformation, "Pulse/SW/Dealer CH Fund Reconciliation Process"

mcro_delete_all_fund_tables_Exit:
Exit Function
mcro_delete_all_fund_tables_Err:
MsgBox Error$
Resume mcro_delete_all_fund_tables_Exit
End Function
 

jdraw

Super Moderator
Staff member
Local time
Today, 00:33
Joined
Jan 23, 2006
Messages
15,379
What exactly are you trying to do? If the intent is to remove all records from all tables, why does the user have some option?
 

molsen

Registered User.
Local time
Yesterday, 21:33
Joined
Sep 13, 2012
Messages
50
What exactly are you trying to do? If the intent is to remove all records from all tables, why does the user have some option?

The user has to import information during the working week, and on the Monday, clear down the database ready for the import of data for that week, and so on each week. He will need to clear it down, but I want a warning to come up in case he clicks on it unintentionally and deletes everything ahead of schedule
 

jdraw

Super Moderator
Staff member
Local time
Today, 00:33
Joined
Jan 23, 2006
Messages
15,379
Many developers would have a procedure which would do something like

- Ask the user if this is Starting an Import for the new week?
- If YES, then backup the old data to some known location
Delete all records from the appropriate tables
Do a compact and repair of the database
Do the import via a procedure
Test for any import errors -- and advise appropriately
--- regular processing
If NO, then regular processing.

User must answer explicitly YES to initiate the import.

Best approach is to not allow the user/or make it difficult to bypass a standard procedure.

Good luck.
 

Users who are viewing this thread

Top Bottom