Results 1 to 3 of 3

Thread: VBA Basics

  1. #1
    Join Date
    Jan 2004

    Unanswered: VBA Basics

    Hi there. I have never actually taken a coding class before, so a lot of work on Access is stumping me. I will, however, say that the code seems very understandable up to a point. What I do not understand is the syntax.
    I do not believe that what I am trying to accomplish is difficult, or that it requires a great amount of coding. With that in mind I would greatly appreciate it if somebody could fill me in on the following, as well as any other "basics" that you think may follow suit, or pop up as problems sooner than later. What I am mainly looking for is:

    What is Me used for? (My guess is it points to whatever object follows?)

    What is ! used for? (I'm not sure, but I think I sometimes see this interchanged with a period.)

    What is . (period) used for? (If this is the same as ! please ignore)

    What is | used for? (I believe this is simply a seperator?)

    Last whey are () and [] use respectively? Is one always necessary, whereas the other is only conditionally necessary? As far as I can tell [] need to go around object names (forms, tables, etc.), and () is used if I am referencing objects within objects?

    I could very well be completely off base with many of these, and would greatly appreciate some help.

  2. #2
    Join Date
    Jun 2002
    Mpls/St.Paul area
    Me is a short cut. It allows you to refer to controls without refering to the long name of the object that they are on.
    e.g. in the code 'behind' a form you can use syntax like me.MyControl, instead of Forms!myform.MyControl

    ! has a variety of object over and above just talking loudly. Here is some Access help info
    The ! operator
    The ! operator indicates that what follows is a user-defined item (an element of a collection). For example, use the ! operator to refer to an open form, an open report, or a control on an open form or report.

    Identifier Refers to
    Forms![Orders] The open Orders form.
    Reports![Invoice] The open Invoice report.
    Forms![Orders]![OrderID] The OrderID control on the open Orders form.

    The . (dot) operator
    The . (dot) operator usually indicates that what follows is an item defined by Microsoft Access. For example, use the . (dot) operator to refer to a property of a form, report, or control. You can also use the . (dot) operator to refer to a field value in an SQL statement, a Microsoft Visual Basic for Applications method, or a collection. Identifier Refers to
    Reports![Invoice]![ShipName].Visible The Visible property of the ShipName control on the Invoice report.
    SELECT Employees.EmployeeID, Orders.OrderID
    FROM Employees INNER JOIN Orders ON Employees.EmployeeID = Orders.EmployeeID; The EmployeeID field from the Employees table and the Orders table.
    DoCmd.Close The Close method in Microsoft Visual Basic.
    Forms![Orders].Properties.Refresh The Refresh method of the Properties collection of the Orders form.

    Although Andy Baron, the author of , strongly disagrees.

    For bang vs dot (! vs .) also see this site,
    This site also talks about the use of square brackets.
    This is the day the Lord has made, I will rejoice and be glad in it.

  3. #3
    Join Date
    Jan 2004
    Thank you. I greatly appreciate the information.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts