Macro

  • Thread starter Thread starter Sue Enman
  • Start date Start date
S

Sue Enman

I have an excel form that is linked to an excel database.
I want to assign a macro that will automatically do the
following: Hit file save (or the diskette on the tool
bar) --THIS WILL BRING UP A DIALOG BOX THAT WILL AS YOU IF
YOU WANT TO CREATE A NEW RECORD --- this does not record
when recording a macro. Does anyone know how to write the
macro so this dialog box will appear??

any suggestions would be appreciated...

Sue
 
I'm not sure exactly what you want to do when you "create new record", but the following will get you the dialog box. Just replace the comments with the code you want executed. Also make sure this is in the workbook module.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean
Dim Answer As Intege
Answer = MsgBox(prompt:="Do you want to create a new record?",
Buttons:=vbYesNo
If Answer = vbYes The
'code to to create new recor
Els
'code to overwrite existing recor
End I
End Su
 
Back
Top