Results 1 to 10 of 10
  1. #1
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486

    use hyperlink to open form based on value in the field

    I have a continuous form that lists all unapproved invoices. I would like to have a hyperlink at the end of each row that says Review and will open another form that queries the details of the unapproved invoice based on the invoice number in the current row.


    Thanks for any help

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    AFAIK, that's just a DoCmd.OpenForm code in textbox Click event. The textbox can be formatted to appear as hyperlink with the DisplayAsHyperlink property.

    DoCmd.OpenForm "formName", , , "ID=" & Me.ID
    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
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    The form will be based on a query and I need to pass the value of the Invoice Number of the row I am clicking so the form only opens the Invoice Detail rows from the invoice number I clicked on. I dont just need to open the form, Basically I need to open the form and say find invoice detail records with this invoice number.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    The example code will open form filtered to only record(s) that meet the given criteria. I used generic ID as example. Use invoice number if you want.
    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
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    I tried this and it is not working

    DoCmd.OpenQuery("q_UnapprovedInvoices", , , "InvoiceNumber=" & Me.InvoiceNumber)

  6. #6
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    DoCmd.OpenQuery "q_UnapprovedInvoices", , , "InvoiceNumber=" & Me.InvoiceNumber
    Says
    Compile Error: Wrong number of arguments or invalid property assignment

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    My code is to open form, not a query.
    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.

  8. #8
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    ok, I changed it to a form

    DoCmd.OpenForm "f_ApproveInvoice", , , "InvoiceNumber=" & Me.InvoiceNumber

    And get - Run-Time error 3464 - Data Type mismatch in criteria expression

    If I try to do it in the macro builder and put InvoiceNumber=Me.InvoiceNumber in the Where section it pops up the dialogue box and asks you to enter the invoice number and then it works.

    So that is closer but i am not sure if I did the where clause correct in the macro builder

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Is InvoiceNumber a text type field? Need apostrophe delimiters.

    "InvoiceNumber='" & Me.InvoiceNumber & "'"

    Date/time fields use # delimiter, number fields do not have delimiter.
    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.

  10. #10
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    Yes, Invoice number is a text type field.

    I have used
    DoCmd.OpenForm "f_ApproveInvoice", , , "InvoiceNumber=" & Me.InvoiceNumber & ""

    And it still gives me the data type mismatch error

    Then I realized that you had typed it different

    DoCmd.OpenForm "f_ApproveInvoice", , , "InvoiceNumber='" & Me.InvoiceNumber & "'"

    This one has a single quote (Apostrophe) before the quote after the = sign and a single quote (Apostrophe) between two end quotes. (added in case someone else sees this post.

    It is working now.
    Thanks

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

Similar Threads

  1. Browse and Open Folder Based on Matching Form Field
    By Tomfernandez1 in forum Access
    Replies: 11
    Last Post: 02-26-2013, 01:04 PM
  2. Replies: 3
    Last Post: 08-18-2012, 03:21 PM
  3. open hyperlink in form - using VB
    By ender in forum Programming
    Replies: 1
    Last Post: 02-17-2012, 04:14 AM
  4. Replies: 2
    Last Post: 08-11-2011, 10:02 AM
  5. Hyperlink to open a form
    By accessnewb in forum Access
    Replies: 12
    Last Post: 07-27-2011, 07:33 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