Page 1 of 2 12 LastLast
Results 1 to 15 of 30
  1. #1
    PrimaryKey is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    42

    Datasheet hyperlink that opens a popup form

    Hello all.



    I am building an Order form that allows users to add items to the order, which are then displayed in a datasheet style subform below the "Add Item" button before saving/completing the order. Some of the products require a configuration, which is handled via a popup subform based on the type of product the user selects. The datasheet style subform has a record source of query.

    In the datasheet all of the OrderItems are listed, including Price/Qty/Subtotal, etc. And for items that have a configuration the ConfigID for that item is also listed in a textbox. I want to make that ID# a hyperlink that when clicked opens the Configuration form (a popup form) to the specified record. I have used OpenArgs before to open a form and pass a variable to it, but always using a button, never a textfield that includes a hyperlink.

    I've read a few other threads on here and on other Access forum sites, but haven't found anything yet that allows me to accomplish my objective. Could anyone offer me any insight into how this might be accomplished? I'm not really sure where to start to be able to do this.

  2. #2
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Could you just set the "Is Hyperlink" property of the ID's textbox to "Yes", then put your normal Docmd.Openform code in the On Click event of the text box?

    Code:
    DoCmd.OpenForm "Formname", , , "ConfigID=" & Me!ConfigID, , acDialog

  3. #3
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,653
    you can just use the click event of the textbox. If you want the appearance of a hyperlink just format the text.

  4. #4
    PrimaryKey is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    42
    Quote Originally Posted by kd2017 View Post
    Could you just set the "Is Hyperlink" property of the ID's textbox to "Yes", then put your normal Docmd.Openform code in the On Click event of the text box?

    Code:
    DoCmd.OpenForm "Formname", , , "ConfigID=" & Me!ConfigID, , acDialog
    Thank you very much! I'll try that.




    Quote Originally Posted by moke123 View Post
    you can just use the click event of the textbox. If you want the appearance of a hyperlink just format the text.
    I'm going to try that - thank you!

  5. #5
    PrimaryKey is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    42
    Thank you all for your comments. I'm still having one problem. The popup form that opens has a field called ConfigID (which is the PK for the Config table) that has a control source of the Config table's ConfigID. The problem is when I try to use OpenArgs to pass the ConfigID and set the value of the ConfigID, I get an error saying that the value cannot be set.

    How can I use OpenArgs (or similar) to open the popup form the specified record? Basically, the datasheet has a field called ConfigID, and I just want users to be able to click on that to open the Configurations subform at the specified record, but can't figure out how to do that.

  6. #6
    PrimaryKey is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    42
    When I put this on the sending form buttons click event, such the Me.ConfigIDtxt is the textfield containing the ConfigId I want to open:
    DoCmd.OpenForm "order_BoomConfig_edit", , , , , acDialog, Me.ConfigIDtxt

    And this on the sending side (where ConfigID is the field that contains the Config table's ConfigID PK)
    strOpenArgs = Me.OpenArgs
    Me.ConfigID = strOpenArgs

    The variable is passed - I can verify that by outputting it to a MsgBox on the receiving side, but I get an error stating that "You cannot assign a value to this object".

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Perhaps you should post a copy of your database.

  8. #8
    PrimaryKey is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    42
    Given the amount/nature of the data in it, it might actually be easier for me to build a sample db with this feature. I can do that tomorrow morning if you;d like. Wouldn't take but 20 minutes.

    In the mean time if you have any suggestions let me know. I'm just trying to open a popup form to specified record based on teh record's ID that's on the main form. I can pass the recordID to the popup, but don't know how to get the popup to open to that particular record.

  9. #9
    John_G is offline VIP
    Windows 10 Access 2016
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    If you are opening the popup to view an existing record, then setting the value of the config_ID with Me.ConfigID = strOpenArgs is the wrong way to do it. The effect of that statement is to try to change an existing value of ConfigID, in whatever record happens to be first when you open the form. The reason for the error message is probably because ConfigID is an autonumber field, which you can't assign values to.

    If you want to open the form to an existing record, i.e. one with a known ConfigID, the better way is to not use OpenArgs, but to use the Where option in the OpenForm command instead:

    DoCmd.OpenForm "order_BoomConfig_edit", , ,"ConfigID = " & Me.ConfigIDtxt , , acDialog

    What this actually does is apply a filter to the records displayed on the popup form. In this case it is only one record, but the Where option (in blue above) can also be used to display all records for one state, for example, or for a given date.

  10. #10
    PrimaryKey is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    42
    Quote Originally Posted by John_G View Post
    If you are opening the popup to view an existing record, then setting the value of the config_ID with Me.ConfigID = strOpenArgs is the wrong way to do it. The effect of that statement is to try to change an existing value of ConfigID, in whatever record happens to be first when you open the form. The reason for the error message is probably because ConfigID is an autonumber field, which you can't assign values to.

    If you want to open the form to an existing record, i.e. one with a known ConfigID, the better way is to not use OpenArgs, but to use the Where option in the OpenForm command instead:

    DoCmd.OpenForm "order_BoomConfig_edit", , ,"ConfigID = " & Me.ConfigIDtxt , , acDialog

    What this actually does is apply a filter to the records displayed on the popup form. In this case it is only one record, but the Where option (in blue above) can also be used to display all records for one state, for example, or for a given date.
    John_G - Wow! You're brilliant! Just tried it and it worked. And thank you for the outstanding explanation.

    Could I ask a followup? I'm one of those people who barely knows VBA (just learning it), so I often find code snippets I need to use while searching the web, without fully understanding the parameters, etc. OpenArgs is one of those.

    I assume the commas separate the parameters, and that you you included "ConfigID = " & Me.ConfigIDtxt in the spot for that parameter? Is that right?

    Anyway - extremely helpful. Thank you. There are many, many places this will come in handy. I literally can't thank you enough. Perhaps I'll name my first born John!

  11. #11
    John_G is offline VIP
    Windows 10 Access 2016
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I assume the commas separate the parameters, and that you you included "ConfigID = " & Me.ConfigIDtxt in the spot for that parameter? Is that right?
    Exactly. Here is a link to the help page that opens when you press F1 with the cursor in the VBA 'OpenForm':

    https://msdn.microsoft.com/en-us/VBA...-method-access

    You'll notice at the end of that page the OpenArgs way of accomplishing what you were looking to do.

    Glad I was able to help out.

  12. #12
    PrimaryKey is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    42
    John_G: Thank you again. Very helpful.

    Last question - I see on that page exactly what you're talking about - all the parameters are clearly listed. Hypothetically, if I wanted to pass two parameters through the WHERE constraint, would that be possible? I didn't see an example on that page, but I assume the syntax would just involve using AND and then defining the second constraint?

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    Have as many criteria as you want. However, I don't understand the semi-colon following the & in the example.

    Consider this example:

    DoCmd.OpenForm "Orders", , , "CustomerID=" & Me.cbxCust & " AND OrderDate>#" & Me.cbxDate & "#"
    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.

  14. #14
    DavidMcA18 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2016
    Posts
    20
    Hi Guys, this post helped me for this but I have a problem with this

    I have this linked up on a datasheet and when i click to open the form i get a pop up text box asking about parameters. After i click close it opens the form with no data.

    Can anyone suggest anything?

  15. #15
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    If its asking for parameters its indicating that one of the fields is either missing or the delimiters are incorrect for that datatype
    By clicking close, you haven't provided the info needed by Access, so the form is empty.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Hyperlink opens duplicate window
    By gunitinug in forum Access
    Replies: 1
    Last Post: 09-04-2017, 05:39 PM
  2. Replies: 1
    Last Post: 06-22-2017, 12:15 PM
  3. Replies: 8
    Last Post: 09-09-2015, 07:07 AM
  4. Replies: 1
    Last Post: 02-29-2012, 09:38 AM
  5. Form opens table in datasheet view
    By franklbl in forum Forms
    Replies: 9
    Last Post: 03-23-2011, 09:43 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