Tuesday, September 13, 2011

How to Declare Variables As a Form In VBA


Microsoft Visual Basic for Application (VBA) controls use variables to store temporary information in the Access procedures, Word modules or Excel workbooks during the application execution. You need to use the word "Dim" (Dimension) followed by the chosen variable name and the word "As" followed by the variable type in order to declare a VBA variable. The VBA control variables represent a control on a form, report or section within another control. By declaring a variable as a form, you can reuse the existing VBA control objects.

Instructions

    • 1
      Click the "Start" button in Windows and select "Microsoft Office" and then "Microsoft Visual Basic for Applications."
    • 2
      Enter the following code in the window:
      Dim order As Form
      DoCmd.OpenForm "Customers"
      Set order = Forms!Customers
      Form_Customers.Visible = True
      Form_Customers.Caption = "New Customers"
    • 3
      Click "File" and "Save" to save the VBA script with the "order" form variable.

No comments:

Post a Comment