Forms |
3.6 Using the Same Button(s) on Multiple Forms. |
Cheryl Whiteford, CJW Computer Services Pty Ltd of Monterey Keys, Queensland AU. |
When using the same buttons on more than one form, create a Global Module and include any of the functions below. Because you do not have these Event procedures in every form, this method should save space in your Database. Create the Button/s on your forms. Button On Click Delete =cjwDelete( ) Save =cjwSave( ) Undo =cjwUndo( ) Add =cjwAdd( ) First =cjwFirst( ) Next =cjwNext( ) Last =cjwLast( ) Previous =cjwPrevious( ) Close =cjwClose("frmName") where frmName is the Name of your Form Open =cjwOpen("frmName") Preview =cjwPreview("rptName") where rptName is the Report Name Print =cjwPrint("rptName") Run =cjwRun("qryName") where qryName is the Name of your Query '---- basGlobal ---- Option Compare Database Option Explicit Function cjwDelete() On Error GoTo Err_cjwDelete DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70 Exit_cjwDelete: Exit Function Err_cjwDelete: MsgBox Err.Description Resume Exit_cjwDelete End Function Function cjwSave() On Error GoTo Err_cjwSave DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, acMenuVer70 Exit_cjwSave: Exit Function Err_cjwSave: MsgBox Err.Description Resume Exit_cjwSave End Function Function cjwUndo() On Error GoTo Err_cjwUndo DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70 Exit_cjwUndo: Exit Function Err_cjwUndo: MsgBox Err.Description Resume Exit_cjwUndo End Function Function cjwAdd() On Error GoTo Err_cjwAdd DoCmd.GoToRecord , , acNewRec Exit_cjwAdd: Exit Function Err_cjwAdd: MsgBox Err.Description Resume Exit_cjwAdd End Function Function cjwFirst() On Error GoTo Err_cjwFirst DoCmd.GoToRecord , , acFirst Exit_cjwFirst: Exit Function Err_cjwFirst: MsgBox Err.Description Resume Exit_cjwFirst End Function Function cjwNext() On Error GoTo Err_cjwNext DoCmd.GoToRecord , , acNext Exit_cjwNext: Exit Function Err_cjwNext: MsgBox Err.Description Resume Exit_cjwNext End Function Function cjwLast() On Error GoTo Err_cjwLast DoCmd.GoToRecord , , acLast Exit_cjwLast: Exit Function Err_cjwLast: MsgBox Err.Description Resume Exit_cjwLast End Function |