Results 1 to 15 of 15
  1. #1
    ADiaz22 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2013
    Posts
    10

    Exclamation OpenForm Macro Not Working from a Combo Form!

    Hi there,



    I am currently building a database in which users can see certain Site Locations and when they click on it, it'll open up to the Site Details. So I made two forms: "Site List" and "Site Details". When I tried to link the two together using the "OpenForm" macro "on click" it gives me two errors that I pasted print screens into a word document of. I made sure there was a PK and I wanted to make sure that the site that is clicked, opens to the right site details form so I added in the function an "=[Site ID]"... But it still isn't working. Please refer to the Word document for the error messages and also to see which macro I am trying to use.AccessErrors.zipAccessErrors.zip


    Any help would be much appreciated!!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    The WHERE CONDITION is incomplete. It needs to be an expression. I use only VBA and the code would be:

    DoCmd.OpenForm "Site Details" , , , "[Site ID]=" & Me.[Site ID]

    Might consider a form/subform arrangement.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ADiaz22 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2013
    Posts
    10
    If you look at the Student Database template, they give you the option to open up a student details form when you click on the student in the Student List form. That is what I'm trying to recreate here, but I can't seem to get the expression right. I'm not very familiar with VBA and only really know Basic/Intermediate applications on Access. So I notice if I leave the WHERE CONDITION blank, it opens the Site Details form to the very first form, regardless of which one I choose. What expression do I put in order to have the right Site open when I click it? I tried the code you gave me but it still doesn't work.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    That template uses an embedded macro. Viewed with Access 2007, the criteria expression used is:

    ="[ID]=" & Nz([ID],0)

    Your forum profile says Access 2007 but your images reflect Access 2010/2013.

    If you want to provide your db, I will attempt to troubleshoot later with 2010.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ADiaz22 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2013
    Posts
    10
    Ok no problem. Funny, my Access says "Access 2007-2010" so maybe I misunderstood on which version I had. Here's the database I'm trying to build. As you can see on the Site List form, the Site IDs look like hyperlinks so it can be clicked to open the Site Details. So that's where I need help. Thank you so much for looking into this!

    Fieldwork Database.zip

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    There are enough differences between 2007 and 2010 even though they both create accdb files that sometimes 2007 has issues with file built in 2010. For instance, my Access 2007 doesn't recognize your file.

    Your Site ID is a text value. Text values must be delimited with apostrophe (use # for date/time):

    "[Site ID]='" & [Site ID] & "'"

    Odd, I made that edit and removed the leading = sign. The form opens without error but it is not filtered even though it says it is.

    I gave up trying to fix your Contracts form embedded macro. I converted to VBA code and that works.

    Private Sub SiteOpen_Click()
    DoCmd.OpenForm "Site Details", , , "[Site ID]='" & Me.[Site ID] & "'"
    End Sub


    You have ID fields set as primary key but not using them as the primary/foreign key. Set SiteID as primary/foreign key. The ID fields are useless with the table relationships as is.

    Advise no spaces or special characters (underscore is exception) in names.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    ADiaz22 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    10
    Thank you very much! We are one step closer! So now, when I click the site, it keeps going to the first of the list instead of the site that I actually would like to show up. I did change the SiteID as primary key so I'm not sure where I should go from here. Thank you again for your time, patience and effort!

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    That's what was happening to me with the macro. Did you try VBA?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    ADiaz22 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    10
    When I tried it as a VBA this is the error I received:


  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Your image did not appear to load.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    ADiaz22 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    10
    I tried again... But I'll also add it as an attachment just in case it doesn't load again. Thanks again!
    Click image for larger version. 

Name:	AccessErrorVBA.jpg 
Views:	8 
Size:	199.9 KB 
ID:	13020

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    All I can say is it works for me. Provide your revised db for analysis.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    ADiaz22 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    10
    Sorry, been busy. Here's the database with the VBA you provided for me. Fieldwork Database.zip

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    That's weird behavior.

    I copied the SiteList form, deleted the old one, renamed the copy. Now I get error message: Object doesn't support this property or method.

    That's more weird behavior.

    I downloaded your first posted db and tried to replicate my earlier success and even that won't work.

    I tried importing objects to a new db, still won't work. I deleted both forms and rebuilt. The code works.

    I rebuilt the SiteList form in your posted db and that seemed to fix the issue. Form must be corrupted. You will have to rebuild it.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    ADiaz22 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    10
    I solved the problem using the button control and specifying that I had related fields. It built the macro for me and it worked. I no longer have the issues that I had. Thank you for helping!

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

Similar Threads

  1. Sleepless Combo Select not working on form
    By MadeCurler in forum Forms
    Replies: 8
    Last Post: 11-09-2012, 01:05 PM
  2. Replies: 2
    Last Post: 08-18-2011, 10:20 PM
  3. Working of Combo boxes in Form
    By suryaprasad in forum Forms
    Replies: 3
    Last Post: 06-29-2011, 11:54 AM
  4. OpenForm in subform not working
    By eyuen in forum Forms
    Replies: 3
    Last Post: 11-10-2010, 12:03 PM
  5. OpenForm macro
    By tguckien in forum Forms
    Replies: 3
    Last Post: 07-06-2010, 09:12 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