Results 1 to 10 of 10
  1. #1
    rachello89 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    15

    Unhappy VBA code used to work now it does not

    I have a button on a report that opens a form and displays the information for a specific client. Here is the code below:

    Code:
    Private Sub Command14_Click()
    DoCmd.OpenForm "Edit Client", , , "ClientID = " & Me.ClientID
    End Sub
    .

    It worked beautifully, but I recently put the backend on SQL Azure and still use Access for the front end. The button no longer works. You can click all you want and it is not opening that form. I don't know if the transition caused this or something else I did. If someone could point me in the right direction, that would be great. I have some users that are not happy that this does not work anymore.

  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
    Did you put a MsgBox message in the event to make sure the Click event is executing?

  3. #3
    rachello89 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    15
    No I did not. I do not actually know how to do that. Could you tell me how to put that in? I am very new to VBA codes.

  4. #4
    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
    Change your event code to:
    Code:
    Private Sub Command14_Click()
       MsgBox "About to open the 'Edit Client' form!"
       DoCmd.OpenForm "Edit Client", , , "ClientID = " & Me.ClientID
    End Sub

  5. #5
    rachello89 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    15
    Thanks for your reply.

    I typed it in just how it was written, but a message box does not even pop up. I guess that means that the event procedure isn't working. Any ideas?

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Did you do any preliminary testing as you moved the backend to SQL Azure? What did you actually do?
    Do you really have a button on a Report, or is it another Form?

  7. #7
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    Did you verify that the properties pane for the command button actually indicates there is a procedure associated with the On Click event? Might you have renamed to command button? If you do that, Access can no longer associate the code to the button - you have to rename the sub from Command14_Click to NewName_Click().

    John

  8. #8
    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
    Access 2007 also requires your system to be in a Trusted location for the code to execute.

  9. #9
    rachello89 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    15
    Thanks guys for your input! I had been ignoring the yellow security warning bar that is at the top when you open. When I clicked enable content, my code worked. RuralGuy's comment led me to see if that was it, and it was. Thanks for your help!

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Glad you got it working, and thanks for telling us what you did.

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

Similar Threads

  1. My query code doesn't work
    By blacksaibot in forum Programming
    Replies: 2
    Last Post: 03-08-2012, 02:59 PM
  2. Replies: 1
    Last Post: 03-07-2012, 02:00 PM
  3. Code does not work in 64 Bit Access 2010
    By mwolfod in forum Programming
    Replies: 26
    Last Post: 12-12-2010, 04:39 PM
  4. Query doesn't work when launched by code
    By stephenaa5 in forum Queries
    Replies: 1
    Last Post: 10-24-2009, 09:52 AM
  5. VBA Code To Work With MySQL
    By botts121 in forum Programming
    Replies: 0
    Last Post: 07-08-2009, 08:51 AM

Tags for this Thread

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