19 September 2011

Control the Form Using Module



We have created a form with a simple way in which the form has not been added or installed any feature that will help us work quickly - such as print or view current form. On the other hand, we have created a module contains functions that at any time we can call in such an easy way in the objects we have created. Basically, MS Access has feature to run the function in the module we have created but unfortunately, that function can only be applied in a predetermined form, namely through the class module. In contrast with the standard module, which is created as a separate object in the Access Navigation Pane.

MS Access, by enabling the  (Use Control Wizard) and click command Button (Form Control), will guide you to make a command wizard as we created in the module Global_Procedure. Here are the function created in Global_Procedure: Global_Exit, Global_Next, Global_Previous, Global_Last, Global_First, Global_Close, Global_Deletion, Global_Preview, Global_OpenForm, Global_Preview_Unrefreshed, Global_Process_Deletion, Global_Undo, Global_Print, Global_PrintUnRefreshed, Global_AddNew, Global_Find. Those all generated form Button (Form Control) wizard applied in predetermined form event procedure, but with some modifications, we can move them to module Global_Procedure.

We will create the command button as depicted here

in each form we have created. Do the following steps:
  1. Open frmMainAccount in Design View and disable , first.
  2. On the FormHeader, add Form Control Button by clicking Design tab and Button icon in Controls group.
  3. Go to Command Button property sheet and set the following properties:
    1. Name = GoToFirst
    2. Caption = First
    3. Picture = select Go To First from the available list of picture
    4. ControlTipText= Go to first record
    5. On Click = =Global_First()
  4. Do step number 2 for the following commands:
    1. Go to previous, Command Button property:
      1. Name = GoToPrevious
      2. Caption = Prev
      3. Picture = select Go To Previous from the available list of picture
      4. ControlTipText= Go to previous record
      5. On Click = =Global_Previous()
    2. Add new record, Command Button property:
      1. Name = AddNewRecord
      2. Caption = Add
      3. Picture = select Go To New from the available list of picture
      4. ControlTipText= Add new record
      5. On Click = =Global_AddNew()
    3. Go to next, Command Button property:
      1. Name = GoToNext
      2. Caption = Next
      3. Picture = select Go To Next from the available list of picture
      4. ControlTipText= Go to next record
      5. On Click = =Global_Next()
    4. Go to last, Command Button property:
      1. Name = GoToLast
      2. Caption = Last
      3. Picture = select Go To Last from the available list of picture
      4. ControlTipText= Go to last record
      5. On Click = =Global_Last()
    5. Close form, Command Button property:
      1. Name = CloseForm
      2. Caption = Close
      3. Picture = select Exit Doorway from the available list of picture
      4. ControlTipText= Close this form
      5. On Click = =Global_Close()
    6. Delete record, Command Button property:
      1. Name = DeleteRecord
      2. Caption = Del
      3. Picture = select Delete Record from the available list of picture
      4. ControlTipText= Delete current record
      5. On Click = =Global_Deletion()
    7. Undo last action, Command Button property:
      1. Name = UndoLastAction
      2. Caption = Undo
      3. Picture = select Undo from the available list of picture
      4. ControlTipText= Undo last action
      5. On Click = =Global_Undo()
    8. Find record, Command Button property:
      1. Name = FindRecord
      2. Caption = Find
      3. Picture = select Binoculars (Find) from the available list of picture
      4. ControlTipText= Find record
      5. On Click = =Global_Find()
  5. Go to form properties and set the following properties:
    1. Caption = Chart of Account - Main Account
    2. Record Selectors = No
    3. Navigation Button = No
  6. Final display will lok like this:

No comments :

Post a Comment