Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    sparker75 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jul 2018
    Posts
    107

    It is coming from the form. so would it be sSQL = sSQL & "WHERE OrderNum= " Form & Me.OrderNum ?

  2. #17
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No, "Me" refers to the form so that bit you added needs to be removed.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #18
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I'm sorry, we're in a function in a standard module? If so you need the full reference instead of Me:

    sSQL = sSQL & "WHERE OrderNum= " & Forms!FormName.OrderNum
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #19
    sparker75 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jul 2018
    Posts
    107
    It works! Thank you. But I would like to use it on many forms. How would I do this?

  5. #20
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Pass the order number to the function as an input parameter and use that instead of the form reference. More here if needed:

    http://www.baldyweb.com/Function.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #21
    sparker75 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jul 2018
    Posts
    107
    Sorry but this link does not provide me enough detail. OrderNum is my common parameter on each form. Could I not use something like this sSQL = sSQL & "WHERE OrderNum= " & Forms!ME.OrderNum so its not specific to a form?

    Also I tried this but I get an error

  7. #22
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No, that wouldn't work. Like:

    Public Function fnCalcPct(lngOrderNum As Long) As Variant

    and then use lngOrderNum instead of the form reference. You'd add it when calling the function as well, as shown in the link.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Create a Calculation to Produce Text
    By DigitalAdrenaline in forum Access
    Replies: 6
    Last Post: 08-12-2018, 10:55 AM
  2. Text Box Change Color on Calculation
    By MarkV in forum Access
    Replies: 2
    Last Post: 03-10-2015, 05:34 PM
  3. Help with Text calculation
    By yagerlegi in forum Forms
    Replies: 4
    Last Post: 12-04-2014, 08:54 PM
  4. Replies: 12
    Last Post: 11-13-2014, 12:08 PM
  5. Replies: 29
    Last Post: 06-05-2014, 09:34 AM

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