Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    May 2001
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA modules (2003/SP2)

    I am new to Access. I searched the forum and found a VBA macro that I believe will solve a problem for me but now I have another problem in that I do not know how to get it to work. The macro should be linked to "on enter" on a form field. How do I get this VBA macro in my form? I know it has something to do with modules. I'm sorry to ask such a basic question, but I cannot find the answer in Access Help or on the Microsoft website and I am tired of trying to find the answer by Googling.

    Thanks,

    Brad

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VBA modules (2003/SP2)

    Open the form in design view.
    Select the text box (or other control).
    Activate the Event tab of the Properties window.
    Click in the On Enter box.
    Select [Event Procedure] from the dropdown list.
    Click the builder button, i.e. the ... to the right of the dropdown arrow.
    This will open the Visual Basic Editor, and create the 'skeleton' of the event procedure for you:

    Private Sub ControlName_Enter()

    End Sub

    where ControlName is the name of the text box.

    You can type the code you need between the Sub ... and End Sub lines.

  3. #3
    New Lounger
    Join Date
    May 2001
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA modules (2003/SP2)

    Thank you! Now, in this macro that I got from this forum, it has the expression "txtTelephone" in it. I am assuming that this is referring to the text string in the field "Telephone," correct? So if the field I am putting this in is labeled "HomePhone" I should replace "Telephone" with "HomePhone" right?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VBA modules (2003/SP2)

    I don't know exactly to which code you are referring, but I assume that txtTelephone is the name of the control (text box) bound to the Telephone field. If the text box on your form is named HomePhone, use HomePhone instead of txtTelephone.

    (The prefix txt is just a convention used by many developers to indicate a text box. It has no intrinsic meaning)

  5. #5
    New Lounger
    Join Date
    May 2001
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA modules (2003/SP2)

    >>(The prefix txt is just a convention used by many developers to indicate a text box. It has no intrinsic meaning)

    Oh! No wonder I was getting error messages about the variable not found. Thanks for all your help!

Posting Permissions

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