Results 1 to 14 of 14
  1. #1
    bfruge is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    9

    Query Criteria Help

    I followed a tutorial online that helped me add a query to create a preview report button so that i can print a receipt from a student invoice.
    The report runs fine, as long as I enter the invoice ID #. I want to bypass that step and have the query and report (they are linked together?) open for the current record only.



    The current query criteria is: [Forms]![Invoice]![InvoiceID]

    This database is for student registration.
    I have an invoice form with a subform that totals beautifully.
    When I enter the invoice id, the report previews and I can print from there.
    I simply want to have the command button open the current record to show the preview of the receipt to print.

    I have student data inside the database, but if the file is needed, I can create a copy and remove student data.
    I have searched online and someone mentioned a crosstab query, but my eyes are crossed trying to figure this out. Thanks in advance.

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    make a query that opens on the current record:
    select * from table where [id]=[Forms]![Invoice]![InvoiceID]

    the report would be based on that query.

  3. #3
    Minty is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    As long as that form (form name "Invoice") is open your query shouldn't prompt you for that criteria?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    bfruge is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    9
    Does this string go into the criteria field on the query? select * from table where [id]=[Forms]![Invoice]![InvoiceID]

  5. #5
    bfruge is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    9
    Quote Originally Posted by Minty View Post
    As long as that form (form name "Invoice") is open your query shouldn't prompt you for that criteria?
    It does, even with invoice form open. Then sometimes it will open without prompting.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    No idea what is happening. If you want to provide db for analysis, follow instructions at bottom of my post.
    Last edited by June7; 05-24-2018 at 12:12 PM.
    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
    bfruge is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    9
    Quote Originally Posted by Minty View Post
    As long as that form (form name "Invoice") is open your query shouldn't prompt you for that criteria?
    I just remade the database and now it is working - I can print the current report without the parameter popup as long as I am in the invoice. I am not sure what happened earlier.

  8. #8
    bfruge is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    9
    Quote Originally Posted by bfruge View Post
    It does, even with invoice form open. Then sometimes it will open without prompting.
    When I add the navigation form, I have to enter the invoice ID to print from the button. However, if I am in the invoice form outside of the navigation form, it works without prompting

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Referencing controls on forms on navigation forms requires a specific syntax. Can't look it up now (posting via phone). This would explain why it fails when opening from the nav form. Google it or maybe someone else knows the syntax by heart.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    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
    Minty is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    As Micron has said this is caused by the use of the inbuilt navigation forms, they are loading your forms as Sub-Forms within the navigation form.
    Most of us don't use them and "roll our own" as they can cause various issues, they also only load the forms when selected - so the form isn't there if you open another form.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  12. #12
    bfruge is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    9

    Navigation Form Query Issue

    BCRegFileForumCopyBfrugeNavigationError.zip

    I found several options online, but none of them work for me. You can log into the database using bfruge

    *Edit: I would also like to prepopulate a User field on the invoice form that shows who took in the payment - I have a table called faculty already, just not linked to anything. I need the User field to show the full name of the user based on who logged into the database. Their full name is stored in the Faculty table. I want it to pre-fill based on who is logged in.

    This is a bonus, but I figured while someone is editing I would add in the hopes that it would work. I have been searching online with different results each time.
    Last edited by bfruge; 05-24-2018 at 10:07 AM. Reason: Add one more feature

  13. #13
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Need to save the user ID somewhere. My login procedure populates a textbox on a form that never closes (MainMenu). Then code can reference that textbox whenever needed.

    Alternatives would be global variable or TempVars.

    Why use Embedded Macro? If you are going to use some VBA why not all VBA? I never use macros.

    I also don't use dynamic parameterized queries. Instead of referencing the form in query, use code (VBA or macro) to build criteria string and apply to the WHERE argument of OpenReport method.

    Why is the parameter concatenating text to the form reference? This works:

    [Forms]![StartHere]![NavigationSubform].[Form].[invoiceID]

    as well as:

    [Forms]![StartHere]![NavigationSubform]![invoiceID]
    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
    bfruge is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    9
    Quote Originally Posted by June7 View Post
    Need to save the user ID somewhere. My login procedure populates a textbox on a form that never closes (MainMenu). Then code can reference that textbox whenever needed.

    Alternatives would be global variable or TempVars.

    Why use Embedded Macro? If you are going to use some VBA why not all VBA? I never use macros.

    I also don't use dynamic parameterized queries. Instead of referencing the form in query, use code (VBA or macro) to build criteria string and apply to the WHERE argument of OpenReport method.

    Why is the parameter concatenating text to the form reference? This works:

    [Forms]![StartHere]![NavigationSubform].[Form].[invoiceID]

    as well as:

    [Forms]![StartHere]![NavigationSubform]![invoiceID]
    That worked! Thanks so much -

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

Similar Threads

  1. Replies: 2
    Last Post: 04-02-2015, 12:45 PM
  2. Replies: 1
    Last Post: 11-13-2014, 11:34 PM
  3. Replies: 4
    Last Post: 08-30-2014, 10:23 AM
  4. Replies: 5
    Last Post: 09-20-2012, 03:27 PM
  5. Replies: 5
    Last Post: 08-02-2012, 09:44 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