Results 1 to 9 of 9

Thread: VBA problems

  1. #1
    Join Date
    Jul 2007
    Posts
    1

    Unanswered: VBA problems

    I have two problems with my Access 2003 database:

    1. The VBA code module vanishes completely; and

    2. Most of the event-procedure code for my controls gets moved to the "General" dropdown, and on running 'complie', it reports controls referenced in the code as undefined, even though the controls appear on the form with the name spelt correctly.

    Any help would be most appreciated. Thanks.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    back it up then run a compact and repair?
    George
    Home | Blog

  3. #3
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Quote Originally Posted by shrdlu_junction
    I have two problems with my Access 2003 database:

    1. The VBA code module vanishes completely; and

    2. Most of the event-procedure code for my controls gets moved to the "General" dropdown, and on running 'complie', it reports controls referenced in the code as undefined, even though the controls appear on the form with the name spelt correctly.

    Any help would be most appreciated. Thanks.
    I suspect that you're initiating the event coding from within the VBA editor itself. When you do that, the [Event Procedure] annotation never appears in the control's property sheet. When that happens, (1) run-time VBA doesn't recognize the code as a valid event procedure, and (2) all code gets transferred to the "General" area of VBA.

    The proper way to initialize event programming is by clicking on the appropriate line in the control's property sheet, clicking on the resulting elipses (...), and selecting "Code Builder" from the resulting dialog box. That inserts the proper entry into the property sheet, and initializes the VBA editor to recognize the code as a valid event.

    HTH,
    Sam

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by Sam Landy
    I suspect that you're initiating the event coding from within the VBA editor itself. When you do that, the [Event Procedure] annotation never appears in the control's property sheet. When that happens, (1) run-time VBA doesn't recognize the code as a valid event procedure, and (2) all code gets transferred to the "General" area of VBA.

    The proper way to initialize event programming is by clicking on the appropriate line in the control's property sheet, clicking on the resulting elipses (...), and selecting "Code Builder" from the resulting dialog box. That inserts the proper entry into the property sheet, and initializes the VBA editor to recognize the code as a valid event.

    HTH,
    Sam
    Bah ... I built many an event proc without ever going thru the front door property sheet to init the event ... Most likely, all that is needed is to decompile and recompile to correct this problem - or as George pointed out a C & R.
    Back to Access ... ADO is not the way to go for speed ...

  6. #6
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    I dunow... maybe in later Access versions, such as XP. In earlier versions, I tried doing it that way only to have Access ignore it, and then I realized that the [Event Procedure] annotation was missing in the property sheet. When I put the annotation there manually, it worked.

    Sam

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Let us know what you discover shrdlu_junction. I'm curious on more information you can supply.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  8. #8
    Join Date
    Jun 2004
    Location
    Seattle, WA
    Posts
    601
    Sam I remember deleting the [event procedure] line in one of my first databases because I didn't know what it meant. Even though my code was there, it didn't work till I put [event procedure] back in.
    Ryan
    My Blog

  9. #9
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Quote Originally Posted by rguy84
    Sam I remember deleting the [event procedure] line in one of my first databases because I didn't know what it meant. Even though my code was there, it didn't work till I put [event procedure] back in.
    Ha-Ha, Ryan, I guess we have a lot of good, finally-experienced company. We all learned an invaluable, unforgettable lesson - once!

    Sam

Posting Permissions

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