Results 1 to 8 of 8
  1. #1
    Richie27 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Ireland
    Posts
    159

    Test variable in immediate window

    Hi all,



    I have declared some variables as follows

    Dim costCentre As Integer
    Dim centreCostDesc As Integer
    Dim centreCatDesc As Integer
    Dim begDate As Date
    Dim endDate As Date

    And have assigned them values as follows:

    costCenter = Me.cboCostCentre
    centreCostDesc = Me.cboCentreCostDesc
    centreCatDesc = Me.cboCatDesc

    What I was wondering is how to test these values (which are from an open form with combos with values selected) in the immediate window.

    I typed ?costCentre and hit enter - but nothing happens.

    Any input would be great.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    A Form and its code can only be tested while the form is running. Code in a Standard module can be tested in the immediate window without a problem.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    In addition to Allan's advice, to clarify, you say
    What I was wondering is how to test these values (which are from an open form with combos with values selected)
    which could be construed to mean that cboCostCentre, cboCentreCostDesc and cboCatDesc are on an open Form, but not the Form whose Immediate Window is being used! Are you testing this in the Immediate Window of the Form that actually contains the Comboboxes, or from a different Form?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Richie27 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Ireland
    Posts
    159
    Yes. I am testing it in the Immediate Window of the Form that actually contains the Comboboxes and that form is open with values selected.

    I put the variable declarations and assignments inside the onclick event of a button on the same form but naut happens.

    Hmmmmmm

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did you set a breakpoint so the code will stop?

  6. #6
    Richie27 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Ireland
    Posts
    159
    Quote Originally Posted by RuralGuy View Post
    Did you set a breakpoint so the code will stop?
    Not sure how to do that...hmmm

    I'm sure this is easy......it's always things like that that stump me though......

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    While viewing the code, left click outside the left margin and a dot appears. That is a breakpoint. Run the form and the code shoud stop on the line with the dot. F8 will single step the code.

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    After doing as Allan has advised, placing the Breakpoint immediate after

    costCenter = Me.cboCostCentre
    centreCostDesc = Me.cboCentreCostDesc
    centreCatDesc = Me.cboCatDesc


    when you click the Command Button, the program will stop and take you to the point in code after the assignments have been made. You can then either

    Use ?costCenter in the Immediate Window and hit <Enter>

    or

    Simply hold your Cursor over the Variable, and its Value will appear

    Or, you can forget about setting a Breakpoint and simply add the Bolded line of code, below, to test the Variables:

    Code:
    costCenter = Me.cboCostCentre
    centreCostDesc = Me.cboCentreCostDesc
    centreCatDesc = Me.cboCatDesc
    Debug.Print costCenter & "  " & centreCostDesc  & "  " & centreCatDesc
    Then, In Form View
    • Click on the Command Button
    • Now go into Design View
    • Go to the Code Module
    • Look in the Immediate Window; the Values should be printed there


    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 0
    Last Post: 08-10-2011, 11:59 AM
  2. Object variable or With block variable not set
    By walter189 in forum Programming
    Replies: 1
    Last Post: 07-28-2011, 08:51 AM
  3. Replies: 4
    Last Post: 08-05-2010, 01:26 PM
  4. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  5. Keying in Test answers to Access DB from Written Test
    By CityOfKalamazoo in forum Access
    Replies: 3
    Last Post: 03-01-2010, 08:58 AM

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