Results 1 to 7 of 7
  1. #1
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453

    display temporary variables

    Hi

    debugging a sequence of forms etc which use a temporary variable

    it's not working and I suspect a temporary variable is not being set.

    A google search showed me

    [CODE
    Dim tv As TempVar
    Debug.Print "TempVars.Count: " & TempVars.Count
    For Each tv In TempVars
    Debug.Print tv.Name, tv.Value
    Next]
    [/CODE]

    I tried attaching this as a vba event to a button but that does not work,

    How do I use this code or am I going in totaly the wrong direction

    thanks

    Ian



  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Saying "it does not work" isn't very helpful.

    Does it print anything in the immediate window? Is there an Error message?

    Can you post the entire On_Click event code for the button - that might indicate where the problem could be.

    The code you posted should work fine - it does for me.
    Last edited by John_G; 08-24-2017 at 08:35 PM. Reason: add comment

  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    Works OK for me too, if you remove the bracket after "Next"
    Code:
    Dim tv As TempVar
    Debug.Print "TempVars.Count: " & TempVars.Count
    For Each tv In TempVars
    Debug.Print tv.Name, tv.Value
    Next]

  4. #4
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Quote Originally Posted by John_G View Post
    Saying "it does not work" isn't very helpful.

    Does it print anything in the immediate window? Is there an Error message?

    Can you post the entire On_Click event code for the button - that might indicate where the problem could be.

    The code you posted should work fine - it does for me.
    Hi

    apologies my button code is

    Code:
    Private Sub Command51_Click()
    Dim tv As TempVar
    Debug.Print "TempVars.Count: " & TempVars.Count
    For Each tv In TempVars
        Debug.Print tv.Name, tv.Value
    Next
    End Sub
    When pressed nothing happens, no error message no screen actions at all.

    At the risk of being dispy how to I open the immediate window? as I can't seem to show it hence I can't answer your question

    thanks

    Ian

  5. #5
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Use Ctrl-G to open the immediate pane. Debug.print writes to the immediate window.

  6. #6
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Quote Originally Posted by John_G View Post
    Use Ctrl-G to open the immediate pane. Debug.print writes to the immediate window.
    Many thanks I can now trouble shoot

    cheers

    Ian

  7. #7
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Hi
    just a thank you discovered my temporary variable was not being created so I deleted the code and compacted the database. Re inserted the code and its now creating the variabel

    cheers

    Ian

Please reply to this thread with any new information or opinions.

Similar Threads

  1. removng temporary variables
    By Jen0dorf in forum Access
    Replies: 2
    Last Post: 08-23-2017, 11:10 AM
  2. temporary variables and combo box
    By Jen0dorf in forum Access
    Replies: 2
    Last Post: 06-27-2016, 12:13 AM
  3. Display a temporary message
    By mmaule in forum Access
    Replies: 2
    Last Post: 02-16-2015, 02:41 PM
  4. Temporary Tables
    By ajzpop in forum Access
    Replies: 5
    Last Post: 10-09-2013, 04:30 PM
  5. Temporary tables
    By MDB in forum Forms
    Replies: 3
    Last Post: 08-14-2011, 12:26 PM

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