1 / 17

Programming Database Functions

Programming Database Functions. GUI Event-Based Programming Access Forms Visual Basic for Applications (VBA). Programming in the Windows Environment. GUI G RAPHICAL U SER I NTERFACE. WYSIWYG W HAT Y OU S EE I S W HAT Y OU G ET. EVENT-BASED PROGRAMMING. CUSTOMER FORM.

zofia
Download Presentation

Programming Database Functions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Database Functions GUI Event-Based Programming Access Forms Visual Basic for Applications (VBA) Programming Database Functions

  2. Programming in the Windows Environment GUI GRAPHICAL USER INTERFACE WYSIWYG WHAT YOU SEE IS WHAT YOU GET EVENT-BASED PROGRAMMING Programming Database Functions

  3. CUSTOMER FORM Programming Database Functions

  4. VBA Modules Programming Database Functions

  5. ADD_BUTTON_CLICK Private Sub ADD_BUTTON_Click() Dim newpk as variant On Error GoTo Err_ADD_BUTTON_Click DoCmd.GoToRecord , , AcNewRec newpk = DMax("[CUSTOMER ID NO]", "CUSTOMER") + 1 If isnull(newpk) then newpk = 1 Endif [CUSTOMER ID NO] = newpk Forms![CUSTOMER]![DISCARD BUTTON].Visible = True ‘ ****** make other buttons invisible here ****** DoCmd.GoToControl "CUSTOMER FIRST NAME" Exit_ADD_BUTTON_click: Exit Sub Err_ADD_BUTTON_Click: MsgBox Err.Description Resume Exit_ADD_BUTTON_click End Sub SINGLEUSERONLY Updated 05/09/2000 Programming Database Functions

  6. SAVE_BUTTON_CLICK Private Sub SAVE_BUTTON_Click() On Error GoTo Err_SAVE_BUTTON_Click Forms![CUSTOMER]![DISCARD BUTTON].Visible = False ‘ ******** make other buttons visible here ******** Refresh Screen.PreviousControl.SetFocus Exit_SAVE_BUTTON_click: Exit Sub Err_SAVE_BUTTON_Click: MsgBox Err.Description Resume Exit_SAVE_BUTTON_click End Sub Programming Database Functions

  7. RESET_BUTTON_CLICK Private Sub RESET_BUTTON_Click() ‘ Record Level Reset On Error GoTo Err_RESET_BUTTON_Click SendKeys “{ESC}{ESC}” Exit_RESET_BUTTON_click: Exit Sub Err_RESET_BUTTON_Click: MsgBox Err.Description Resume Exit_RESET_BUTTON_click End Sub Programming Database Functions

  8. RESET_FIELD_BUTTON_CLICK Private Sub RESET_FIELD_BUTTON_Click() ‘ Field Level Reset On Error GoTo Err_RESET_FIELD_BUTTON_Click XNAME = Screen.PreviousControl.Controlname Original = FORMS![CUSTOMER](XNAME).Oldvalue ME(XNAME) = Original Screen.PreviousControl.SetFocus Exit_RESET_FIELD_BUTTON_click: Exit Sub Err_RESET_FIELD_BUTTON_Click: MsgBox Err.Description Resume Exit_RESET_FIELD_BUTTON_click End Sub Programming Database Functions

  9. DELETE_BUTTON_CLICK 1 of 3 Private Sub DELETE_BUTTON_Click() On Error GoTo Err_DELETE_BUTTON_Click Dim SALE_COUNT As Variant Dim STRSQL As String SALE_COUNT = DCount("[CUSTOMER ID NO]", "SALE", _ "[CUSTOMER ID NO] = FORM.[CUSTOMER ID NO]") ‘ more on next page Programming Database Functions

  10. DELETE_BUTTON_CLICK 2 of 3 If SALE_COUNT <> 0 Then MsgBox "Cannot delete this Customer because " & Chr(13) & Chr(10) & _ " it has " & Str(SALE_COUNT) & " Sale Record(s).", 16, "DELETE CUSTOMER" Else If MsgBox("Do you really want to delete this Customer?", 292, _ "DELETE CUSTOMER") = 6 Then STRSQL = "DELETE DISTINCTROW [CUSTOMER ID NO] FROM “ & _ “CUSTOMER WHERE [CUSTOMER ID NO] = " STRSQL = STRSQL & Chr$(34) & _ Forms![CUSTOMER]![CUSTOMER ID NO] & _ Chr$(34) & ” WITH OWNERACCESS OPTION;" DoCmd.RunSQL STRSQL DoCmd.Requery Forms![CUSTOMER]![DISCARD BUTTON].Visible = False End If End If ‘ more on next page Updated 05/09/2000 Programming Database Functions

  11. DELETE_BUTTON_CLICK 3 of 3 Exit_DELETE_BUTTON_click: Exit Sub Err_DELETE_BUTTON_Click: MsgBox Err.Description Resume Exit_DELETE_BUTTON_click End Sub Programming Database Functions

  12. FIND_BUTTON_CLICK Private Sub FIND_BUTTON_Click() On Error GoTo Err_FIND_BUTTON_Click Screen.PreviousControl.SetFocus DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70 Exit_FIND_BUTTON_Click: Exit Sub Err_FIND_BUTTON_Click: MsgBox Err.Description Resume Exit_FIND_BUTTON_Click End Sub Programming Database Functions

  13. PRINT_BUTTON_Click Private Sub PRINT_BUTTON_Click() On Error GoTo Err_PRINT_BUTTON_Click DoCmd.SelectObject acForm, "CUSTOMER" DoCmd.PrintOut acSelection Exit_PRINT_BUTTON_Click: Exit Sub Err_PRINT_BUTTON_Click: MsgBox Err.Description Resume Exit_PRINT_BUTTON_Click End Sub Programming Database Functions

  14. DISCARD_BUTTON_Click (1) Private Sub DISCARD_BUTTON_Click() On Error GoTo Err_DISCARD_BUTTON_Click DoCmd.RunMacro "DISCARDMACRO” ‘(see next page) Forms![customer]![first name].SetFocus Me![reset button].Visible = True Me![delete button].Visible = True Me![find button].Visible = True Me![print button].Visible = True Me![sort button].Visible = True Me![exit button].Visible = True Me![help button].Visible = True Me![add button].Visible = True Me![DISCARD BUTTON].Visible = False Me.NavigationButtons = True Exit_DISCARD_BUTTON_Click: Exit Sub Err_DISCARD_BUTTON_Click: MsgBox Err.Description Resume Exit_DISCARD_BUTTON_Click End Sub Programming Database Functions

  15. DISCARD_BUTTON_Click (2) The DISCARDMACRO contains two commands: RunCommand Undo RunCommand RecordsGoToPrevious Programming Database Functions

  16. MAIN and SUB FORM Programming Database Functions

  17. Sample Sales Form DRAFT ONLY Programming Database Functions

More Related