Results 1 to 8 of 8
  1. #1
    maxis is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2013
    Posts
    30

    How to reference SETVALUE in next Macro CONDITION step?

    In AUTOEXEC Macro I have



    Action = SetValue
    Item = [UserResponse]
    Expression = MsgBox("Confirm xyz",4)

    next macro step

    Action = RunCode Login()
    CONDITION = [UserResponse]=6

    How do a reference the SETVALUE sent back from the MsgBox in the CONDITION column of the RunCode Login()? 6 is Yes, 7 is No.

    It has to work in both Access 2003 and Access 2010.

  2. #2
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742

    Looks right

    The Setvalue action changes the value of a control or other object. In the above example, [UserResponse] is some kind of control, which will end up with a value of 6 (vbYes) if the Yes button is clicked. You need a valid reference to an object that will exist when the macro runs. The complete reference to the control is Forms!formname!fieldname, assuming the control isn't on a subform.

    In the same macro, the same reference format for [UserResponse] should work, just the way you have it.

    The Macro Condition also seems to be available in both versions. For clarity, I'd put parenthesis around ([UserResponse] = 6). I'd also use vbYesNo instead of 4 in the MsgBox and vbYes instead of 6, for clarity, assuming Access macros allow that.

    MsgBox arguments http://www.techonthenet.com/access/c...sgbox_args.php
    MsgBox return codes http://www.techonthenet.com/access/c...msgbox_ret.php
    Setvalue Macro Action http://office.microsoft.com/en-us/ac...001226300.aspx
    Runcode Macro Action http://office.microsoft.com/en-us/ac...001226280.aspx
    Access 2000 Macro Condition http://msdn.microsoft.com/en-us/libr...ffice.10).aspx
    Access 2010 Macro Condition http://office.microsoft.com/en-us/ac...005188429.aspx

  3. #3
    maxis is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2013
    Posts
    30
    Great Links thank you! The UserResponse is a "TEMPORARY" Variable just for the macro to use. It's not on any form. I guess I could create a form, open it, then setvalue, but I was treating it as a simple temp variable for the sake of using it in CONDITION. Anyway around not creating a form with this single field on it?

  4. #4
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    An object named [UserResponse] has to actually exist for that macro code to work. However, you could use an actual temp variable instead.

    Use the SetTempVar macro action instead of SetValue, and then the second reference would be to [TempVars]![UserResponse] and all is well. If that meets your needs, please mark the thread solved. Top of page, under thread tools.

    SetTempVar Macro Action http://office.microsoft.com/en-us/ac...010120216.aspx

  5. #5
    maxis is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2013
    Posts
    30
    no settempvar in access 2003, solution has to work for BOTH access 2003 and 2010

  6. #6
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Okay, well it has to be an object that's addressable by the system, so you have several options
    (1) Put the field on a hidden form or other addressable locatin, and use your original code with full explicit reference.
    (2) Create two global functions, SetUserResponse() and GetUserResponse(), to store and retrieve the value.
    (3) Put the test into a global function PreLogIn() that pops up the messagebox and sets the value somewhere it can be addressed,
    (4) Move the test into the login() code.

    Or, how about (5)
    Code:
    Action = RunCode Login()
    CONDITION = (vbYes = MsgBox("Confirm xyz",vbYesno) )

  7. #7
    maxis is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2013
    Posts
    30
    none of these worked because the access 2010 side won't do anything until AFTER you ENABLE CONTENT, and the whole point is to capture the value BEFORE clicking on ENABLE CONTENT... any of the solutions work fo the 2003 users, but the 2010 users can't even openform before ENABLE CONTENT is set to YES...

  8. #8
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    No, it looks like Microsoft has disabled security for the application in favor of security for the user. http://office.microsoft.com/en-us/ac...010341741.aspx

    Before the database is trusted by the user, the Access application won't allow the user to alter the database in any way. That seems to preclude storing any information about the attempted logon.

    POTENTIAL WORKAROUNDS

    Can you tell me more about what you're trying to find out before the user logs in? You may be able to achieve the desired results by, for instance, launching the application using a script with indirection, rather than by directly launching the database file or Access application.


    UPDATE - THE FOLLOWING WON'T WORK FOR YOUR ISSUE -

    Perhaps you could follow different paths for the two types, based upon the value of this -
    Code:
    Dim varRet As Variant
      
        varRet = SysCmd(acSysCmdAccessVer)
        Debug.Print " * "
        Debug.Print " * *** ACQUIRING ACCESS VERSION  *** * "
        Debug.Print " * "
        Debug.Print " * Your MS Access Version Is " & Application.Version
        Debug.Print " * Your MS Access Syscmd Version Is " & varRet
        Debug.Print " * V11.0 is 2003, V12.0 is 2007, V14.0 is 2010"
    sample results:
    Code:
    * *** ACQUIRING ACCESS VERSION *** * 
    * 
    * Your MS Access Version Is 14.0
    * Your MS Access Syscmd Version Is 14.0
    * V11.0 is 2003, V12.0 is 2007, V14.0 is 2010
    *
    (like I said, doesn't work for your need, since no VBA will run before that ENABLE CONTENT banner is clicked.)

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

Similar Threads

  1. Macro - Open Report, SetValue
    By NLA in forum Programming
    Replies: 1
    Last Post: 11-17-2012, 09:53 PM
  2. SetValue Macro
    By BrianF in forum Programming
    Replies: 1
    Last Post: 10-21-2012, 08:49 PM
  3. SetValue Macro action
    By rkalapura in forum Programming
    Replies: 3
    Last Post: 12-19-2011, 11:54 AM
  4. No SetValue in Macro editor
    By asabri in forum Programming
    Replies: 2
    Last Post: 09-21-2011, 01:39 PM
  5. Problem with SetValue Macro on Form
    By Accidental DBA in forum Forms
    Replies: 3
    Last Post: 04-01-2011, 01:48 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