Results 1 to 5 of 5
  1. #1
    asmith is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    26

    Form / Query issue

    Hello everyone,



    I'm having trouble with a form / query combination and request your assistance. What i'm trying to do is have the "LOC/Trust" number from "Input SubForm" feed into a query and then return the results back to the form. I have tested the query and can manualy plug in a value and the query results show up find in the query but when i try to assign the query to a text box it comes up the the "#Name?" error. Esentialy what i'm trying to do is make a running total for the different components listed in the subform based on the LOC/Trust Number that is linked to the main form.

    I hope this makes sense and that you can help. I've attached a zipped copy of the database for you to view.

    Thank you,
    Andrew

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    Did not look at the attachment. Do not know what is meant by "assign the query to a text box "

    General input: A query can be the record source for a form. Which would be 'assigning' perhaps.

    Or - a query can 'call' a form's textbox value for its criteria. To do that one must use the correct syntax: Forms!FormName.TextboxName

    To design a database & queries you really need to have a textbook in the version you are using. Easily available at Amazon or any big book store. They will have examples of these type tasks.

  3. #3
    asmith is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    26
    Thank you for your reply NTC.

    What i meant by "Assign the query to a text box" is the following.

    I added a text box to the form and under control source i added the following code:

    =[Query1]![SumOfOSLR Current]

    The SQL code for the query is as follows:

    SELECT Sum(Table2.[OSLR Current]) AS [SumOfOSLR Current]
    FROM Table2
    WHERE (((Table2.[LOC/Trust Number])=[forms]![Input SubForm]![Loc/Trust]));


    I hope this helps you understand my issue better. I have a copy of the Access 2007 bible but i can't find exactly what i'm looking for.

    Thank you,
    Andrew

  4. #4
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    One can not call a query into a form's control with =[Query1]

    You can make the form's record source to be that query. or a derivative of this same concept by making a special form with that query record source and inserting it into the main form as a subform.

    But I think what you most likely want to do is to use the DLookUp method. That will enable you to insert a specific table/row/field value into an unbound control (textbox).

    Hope this helps.

  5. #5
    asmith is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    26
    Thank you NTC

    I was able to use the DSUM Function to complete my task.

    For others reference, the control source used in the solution was as follows:

    =DSum("[OSLR Current]","Table2","[LOC/Trust Number] = Forms![Input SubForm]![LOC/Trust]")

    Thanks again,
    Andrew

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

Similar Threads

  1. Query prompt issue
    By zbug in forum Queries
    Replies: 1
    Last Post: 07-31-2010, 04:43 PM
  2. Please Help, Combo Box Query Form Table Issue
    By Keeyter in forum Programming
    Replies: 9
    Last Post: 04-29-2010, 09:15 PM
  3. Query Issue
    By access in forum Queries
    Replies: 1
    Last Post: 01-14-2010, 03:28 PM
  4. Table/Form Issue
    By ginap in forum Access
    Replies: 3
    Last Post: 06-17-2009, 01:12 PM
  5. Annoying Query issue
    By stevendavies in forum Queries
    Replies: 2
    Last Post: 05-08-2006, 02:35 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