Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Ace2014 is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    88

    Command Button to Run Macro, can't find macro

    Hello,



    So with the help of this forum!!! Love you guys, I was finally able to get a much/many needed queries to work.
    But now I have to attach each to its own command button in Access 2007 and that's not as easy as I'd anticipated

    But when I click the button on the form, I get error 2485 .
    Click image for larger version. 

Name:	Error 2485.JPG 
Views:	17 
Size:	13.5 KB 
ID:	16777Click image for larger version. 

Name:	Error 2485 message.JPG 
Views:	17 
Size:	61.6 KB 
ID:	16778
    or error 2950, after the wonderful Access help button lol
    Click image for larger version. 

Name:	Error 2950.JPG 
Views:	17 
Size:	12.5 KB 
ID:	16779Click image for larger version. 

Name:	Error 2950 message.JPG 
Views:	17 
Size:	20.1 KB 
ID:	16780

    I already made sure I spelled the name of my macro correctly :/

    Any more suggestions?
    Attached Thumbnails Attached Thumbnails Module Access.JPG  

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    It looks like you have the name of a Standard Module in your macro. That is not going to work. In the second example, you add parenthesis as to indicate a parameter to a function. That is not going to work. Unfortunately, I do not know how to call a function from a Macro Object. I believe you can but do not remember how because I do not believe it is a practical approach, to use macro objects to all public functions.

    What does your Standard Module have to do with a query? If you want to execute a query from a form, why not use VBA?
    CurrentDB.Execute "NameOfQuery"

  3. #3
    Ace2014 is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    88
    Sorry, I'd been working on a macro for a query too..
    The command buttons have to do with running a macro that will automate the import and append to specific table function.
    But I can't even get into VBA mode. I'm taken directly into the macro builder interface they've created

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    How are you automating the import process? Is there VBA code to do this? Is there a Named Macro Object that will do this when you click it?

  5. #5
    Ace2014 is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    88
    Quote Originally Posted by ItsMe View Post
    How are you automating the import process? Is there VBA code to do this? Is there a Named Macro Object that will do this when you click it?
    That's what you helped me with
    With the browser window.
    I append data into specific tables
    Now I need to attach these macros to their personalized command buttons. Only the runMacro command can't find my macro modules

    Is there a special way to name macro objects?
    Click image for larger version. 

Name:	Name macro.JPG 
Views:	18 
Size:	13.6 KB 
ID:	16782Click image for larger version. 

Name:	Name macro 2.JPG 
Views:	18 
Size:	9.8 KB 
ID:	16783

  6. #6
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    In the form design mode and let's say "On Click" button of property sheet. You should see a button with 3 dots or something like that. Once you click that button (3 dots). It should allow you to select "Macro Builder", "Expression Builder", or "Code Builder". Select "Macro Builder" to build your macro code. Select "Expression Builder" to build your expression. Select "Code Builder" to build your VBA code. Be careful, if you select one of the drop down list.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Two things:

    Don't name your functions and Sub Procedures the same as the name of your Standard Module.
    A Sub Procedure in a Standard module is Private to that module.

    If you want to use a function within a standard module, like m1_Uload_Data, you need to make a Function and you need your Function to be Public.
    Public Function fUpload_Now()
    'Do Something Code
    End Function


    Then, from a click event or something, you can call the function.
    Call fUpload_Now

  8. #8
    Ace2014 is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    88
    Well, with the macro builder, I got various errors as I have displayed on the 1st post.

    For VBA, I'm not quite sure what to write. I mean, if runMacro isn't working, why would it work in VBA?

    Access can't find my macro.

    The Expression builder doesn't have a link to macros

  9. #9
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    If you want to run a macro when you click one of your button, all you need to do is to put the macro name in the "On Click" in the property sheet.

  10. #10
    Ace2014 is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    88
    Quote Originally Posted by lfpm062010 View Post
    If you want to run a macro when you click one of your button, all you need to do is to put the macro name in the "On Click" in the property sheet.
    So when I did that, this is the error message I got:
    Click image for larger version. 

Name:	Name macro.JPG 
Views:	18 
Size:	34.8 KB 
ID:	16784

  11. #11
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You already have VBA code. There is not any need to introduce a macro. Place your export code behind a click event. The other option is to place your export code in a public function and call the function. You attempted to do this but you need to refer to post #7 to correct a couple of things first.

  12. #12
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    There is always more than one way to do the same thing. Learning something new is not a bad thing.

    To answer you question about the error. Do you have the macro "m1_Upload_Data" already build? If the macro is alread build, then I guess it will be harder to bebug without looking at your Access database.

    If you can get it working the other way, then it will be good too.

  13. #13
    Ace2014 is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    88
    I can send you the database, if you send me your email address

  14. #14
    Ace2014 is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    88
    Quote Originally Posted by ItsMe View Post
    You already have VBA code. There is not any need to introduce a macro. Place your export code behind a click event. The other option is to place your export code in a public function and call the function. You attempted to do this but you need to refer to post #7 to correct a couple of things first.
    Ok, well, I tried what you said. Took me a little while.
    But I still got the same error message, that it can't find my m1_Upload_Data macro
    Click image for larger version. 

Name:	Error.JPG 
Views:	17 
Size:	49.2 KB 
ID:	16785
    Click on =pf1_Upload_Data()

  15. #15
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    See attached picture.
    1) Under "Macro", there is "m1_Upload_Data".
    2) In design form property sheet, under "On Click" the name "m1_Upload_Data" is there.

    Click image for larger version. 

Name:	Untitled.png 
Views:	16 
Size:	188.5 KB 
ID:	16786

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

Similar Threads

  1. Find and Replace Macro
    By TrevorM in forum Macros
    Replies: 11
    Last Post: 12-28-2013, 06:11 PM
  2. Macro Command ImportExportText
    By RubyBosch in forum Import/Export Data
    Replies: 3
    Last Post: 12-19-2012, 12:58 PM
  3. Find and Replace Within a Macro
    By bmschaeffer in forum Access
    Replies: 1
    Last Post: 12-20-2011, 11:27 AM
  4. Replies: 0
    Last Post: 01-12-2011, 12:43 PM
  5. run a windodws command from macro
    By broecher in forum Programming
    Replies: 5
    Last Post: 09-12-2010, 04:46 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