Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 31
  1. #16
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Okay found it. However this involves queries, not macros.... So I don't think thats going to work.. However I have another idea...

    Code:
    If DCount("*", "sqCompare_Parts_Matched_1st") > 1 Then
    msgbox "inside the if", , "Redbulls Idea!"
    DoCmd.RunMacro "mcrComparedPartsRepeated", , ""
    Do Until DCount("*", "sqCompare_Parts_Matched_1st") < 1
    msgbox "Inside the Loop", , "Redbulls Idea!"
    Loop
    msgbox "outside the loop", , "Redbulls Idea!"
    End If
    msgbox "outside the IF", , "Redbulls Idea!"
    Okay, so run that... tell me what message box you see.. If you see the following, then the code currently in place should work.


    Inside the if
    Inside the Loop
    Inside the If
    inside the loop
    However I think you are going to see this.....

    Inside the if
    Inside the Loop
    Inside the Loop
    Inside the Loop
    Inside the Loop
    Inside the Loop
    If you see the message boxes as above, use the code below.

    Code:
    If DCount("*", "sqCompare_Parts_Matched_1st") > 1 Then
    DoCmd.RunMacro "mcrComparedPartsRepeated", , ""
    Do Until DCount("*", "sqCompare_Parts_Matched_1st") < 1
    DoCmd.RunMacro "mcrComparedPartsRepeated", , ""
    Loop
    End If
    If you see this
    Inside the if
    Inside the Loop
    Outside the if
    Then there might be an issue with the if statement holding true while in full speed mode.

    ------------------
    If you get something else with those message boxes let me know.. basically we just need to nail down where to put the runmacro command. The wife is gone this evening so I'm free to assist.

  2. #17
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Quote Originally Posted by janbrown56 View Post
    Redbull,

    When I ran the macro the query nor anything else was open, not even the macro. I simply double clicked on it to run it.

    yea my issue was with queries, and having the tables being stored in memory... did not apply to your issue.

  3. #18
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Is it safe to assume this issue is resolved?

  4. #19
    janbrown56's Avatar
    janbrown56 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    18
    Hello Redbull,

    I was out on Friday and have been swamped today so I haven't had a chance to try your suggestion. I am just about to do that. Thanks for checking and I'll let you know.

    Jan

  5. #20
    janbrown56's Avatar
    janbrown56 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    18
    Redbull,

    I'm puzzled. What I'm finding is that when I run the macro by double clicking on it, the VB code that I've entered is not running. I added your suggested code and ran the macro and got NO messages. I must be missing something. I've modified some code of macros before and never had a problem but this isn't working.

    The macro that has the VB code has one action: RunMacro 'mcrComparedPartsRepeated'. I went to Tools -> Macro -> Visual Basic Editor (Previously I had removed all the old code and again converted the macro to Visual Basic). I replaced the existing code with your first suggested code and saved. I did F8 while in VB Editor and found that it stayed inside the loop and I got the messages as follows:
    Inside the if
    Inside the Loop
    Inside the Loop
    Inside the Loop
    Inside the Loop
    Inside the Loop

    Just for haha's and to see what messages would pop up I saved and closed VB Editor, went to the macro in Access and double clicked it to run. NO messages appeared and the mcrComparedPartsRepeated macro ran only one time.

    Why isn't the code in VB Editor running? Am I going about this the wrong way? Like I said, I have messed around with some code (like requery and messages) before by converting the macro to VB Code and using the VB Editor and had no problem.

    Thinking the macro had some underlying problems I created a brand new one from scratch. These are the exact steps I took:
    - New macro.
    - I put the one action line of RunMacro 'mcrComparedPartsRepeated'
    - Saved macro
    - Closed macro
    - Tools -> Macro -> Convert macros to Visual Basic
    - Clicked on the new Macro
    - Added your first code with all the messages (for testing the messages)
    - Hit Save in VB Editor
    - Closed VB Editor
    - Access Database Window > Macros > double click on new macro.

    NO messages..........

    Am I taking the wrong steps to modify the code??
    Last edited by janbrown56; 08-13-2012 at 12:42 PM. Reason: hit enter by mistake.

  6. #21
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Try running this



    Code:
    
    
    Code:
    If DCount("*", "sqCompare_Parts_Matched_1st") > 1 Then
    DoCmd.RunMacro "mcrComparedPartsRepeated", , ""
    Do Until DCount("*", "sqCompare_Parts_Matched_1st") < 1
    DoCmd.RunMacro "mcrComparedPartsRepeated", , ""
    Loop
    End If
    




  7. #22
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Sounds like you don't have the onclick event chosen

  8. #23
    janbrown56's Avatar
    janbrown56 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    18
    Isn't OnClick part of a form? I'm not using a form. I'm just running the macro from Access Database Objects - Macros by double clicking on the macro name or clicking the macro name and then hitting !Run. When I do that it appears that the VB code is not being executed.

  9. #24
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Quote Originally Posted by redbull View Post



    Code:
    If DCount("*", "sqCompare_Parts_Matched_1st") > 1 Then
    DoCmd.RunMacro "mcrComparedPartsRepeated", , ""
    Do Until DCount("*", "sqCompare_Parts_Matched_1st") < 1
    DoCmd.RunMacro "mcrComparedPartsRepeated", , ""
    Loop
    End If
    



    Did the above code work while you f8 though?

  10. #25
    janbrown56's Avatar
    janbrown56 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    18
    Yes, it did work with F8.

  11. #26
    janbrown56's Avatar
    janbrown56 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    18
    Hey Redbull,

    Any ideas why my VB code isn't executing when I just double-click on the macro to run it?

  12. #27
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    I am really shaky at macros and things like that. I ussually deal with forms and vba behind it. I'm going to send you a private message.

  13. #28
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Alright!! things to check when using runcode from within a macro

    include the brackets... I don't think we did this... it would be

    testing123()

    add the () brackets, this might work.

    Another thing I found saying sometimes the function has to be stored in a "module" so you might want to create a new module and name it something unique... drop the entire function code in the module then use the Runcode feature in the macro to call it. Remember alt f11 gets you to the vba editor.


  14. #29
    janbrown56's Avatar
    janbrown56 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    18
    Redbull,

    SUCCESS!! You da bomb! I added the brackets after the function name of the RunCode and the macro repeated as I wanted!!

    Thanks a million for all your help.

  15. #30
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    No problem, thanks for allowing me to assist!

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to repeat data?
    By djclntn in forum Forms
    Replies: 4
    Last Post: 06-29-2012, 05:08 PM
  2. Do not repeat pictures
    By gabrielharo in forum Forms
    Replies: 1
    Last Post: 06-12-2012, 04:58 PM
  3. Repeat Expressions
    By welshmpf in forum Access
    Replies: 8
    Last Post: 09-06-2011, 09:41 AM
  4. IIF Expression - No Repeat Please
    By turnbuk in forum Queries
    Replies: 2
    Last Post: 08-11-2011, 02:50 PM
  5. Problem with Trying to Repeat Records in VBA
    By P5C768 in forum Programming
    Replies: 9
    Last Post: 09-22-2010, 12:09 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
  •  
Tech Forums: Microsoft Office Forums