Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    NewtoIT is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    11

    Need a little help with Allen Browne code

    I am new to code and saw some of Allen Browne's codes. 1 looks very useful to me, http://allenbrowne.com/func-06.html. Having trouble calling it in the immediate window.


    Using Windows 7 64 bit, MS Access 2010, db name is INVLine and table name is also INVLine.
    Questions are: 1) What do I need to change in his code (if anything) to make it run. 2) What do I type in the immediate window to call it?
    I tried ?Call TableInfo (INVLine) and got "Compile Error :Expected Compression:"

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Not sure you can call it that way. Try this behind a button on a test form:

    TableInfo "INVLine"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    NewtoIT is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    11
    Thanks pbaldy, but please elaborate a little. On the on click, as an event procedure? Remember, I am new to VBA code (but eager to learn).

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The function is in a general module?

    Don't use the Call keyword and tablename must be given as a string.

    Try in the immediate window:
    ?TableInfo("INVline")

    Behind a button Click, I would change TableInfo to a Sub instead of Function as it doesn't return anything.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    NewtoIT is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    11
    I tried that and it doesn't work...at least not the ways I know how to write it.
    Private Sub Command0_Click()
    TableInfo "INVLine"
    End Sub

    Allen's page says that it works in the Immediate window so I'm confused.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I tested behind a button and it worked fine. Allen says the output is to the Immediate window, not to call it from there. See attached.
    Attached Thumbnails Attached Thumbnails TestAllen.jpg  
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    NewtoIT is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    11
    It must be me then. I copied Allen's code into a module and named it TableInfo. I then created a form (Form1) and a button (command0) with the on click event of:

    Option Compare Database
    Option Explicit
    Private Sub Command0_Click()
    TableInfo "INVLINE"
    End Sub

    When I click that button on Form1 I get: "Compile Error :Expected Compression:"
    What the heck am I doing wrong?

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Does the code compile before you try to run it? Did you copy Allen's code into a standard module intact (all of it)?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    What a minute; you didn't name the module the same as the function did you? Can't do that, though that's not the error I would have expected.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    NewtoIT is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    11
    Yes I did. I deleted that module and created a new one (Module1) and now I click the button and nothing happens.

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Check the button's OnClick event property. Is it set to [Event Procedure]? Double click the ellipses (...) and that will take you to the VBA procedure. Is the code there? Set a breakpoint and step debug. Review tutorial on debugging at the link at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    NewtoIT is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    11
    It was a 1 GB db so I had to do some work to make it small enough. See attached.
    Attached Files Attached Files

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Worked for me:
    Attached Thumbnails Attached Thumbnails TestAllen2.jpg  
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 21
    Last Post: 04-29-2015, 11:57 PM
  2. Replies: 5
    Last Post: 01-18-2012, 03:46 PM
  3. Filter to a date range ala Allen Brown
    By kekawaka in forum Forms
    Replies: 2
    Last Post: 10-10-2011, 12:19 PM
  4. Replies: 7
    Last Post: 01-26-2011, 08:31 PM
  5. Replies: 1
    Last Post: 08-18-2010, 02:05 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums