Results 1 to 5 of 5
  1. #1
    weilerdo is offline Novice
    Windows 11 Office 365
    Join Date
    Sep 2024
    Posts
    2

    Form Field based on query giving #NAME?

    Hello all, I am hoping to get some help with a head scratchier. I have a Form "Inventory Details" that the control source is a Table "tbl_inventory" on the Form I have an unbound text box "Text6" that I want to be able to visually display a calculation that is based on another Table "tbl_transaction" The Query is "qryTest" which works outside the form with no issue and returns the value. I do not want or need to store the value in a table as its mean to show the current in stock quantity for a given part. I assume it must have something to do with the form not being based on the same table as the query put I am lost as to why I would be getting #NAME? because I have no fields or controls with the same name. I have attached a stripped down version of the database in hopes someone can see my error. Thanks in advance for your support.
    Attached Files Attached Files

  2. #2
    xps35's Avatar
    xps35 is online now Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    299
    You cannot refer to a field in a query like you did. You need to refer to fields in de recordsource of the form.
    I created a new query (qryInventoryDetails) connecting tbl_inventory and qryPartsBalance and used that as the recordsource of the form.

    BTW: you should create relationships on primary keys. So the relationship between tbl_inventory and tbl_transaction must be on (inventory) ID.
    Attached Files Attached Files
    Groeten,

    Peter

  3. #3
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    replace the sql :
    Code:
    =[qrytest]![Balance]
    by:
    Code:
    =DLookUp("Balance","qryPartsBalance","[Part_Num] = '" & [Part_Num] & "'")

  4. #4
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    technical and logical you create lots of problems with that statement.
    A) you never put the result from a calculation in a database
    B) if you do put a result then there are a lot of thing u need to think of like :
    1) never change fields used in a calculation , meaning only add records
    2) a date is needed to compare old result to add newer only
    3) stock also needed to decrease by ordered, if only by sold then u have no stock to sel next order
    this are just few things that came up in my mind there are more things to think ...

  5. #5
    weilerdo is offline Novice
    Windows 11 Office 365
    Join Date
    Sep 2024
    Posts
    2
    This was perfect, thank you both for your help.

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

Similar Threads

  1. Replies: 6
    Last Post: 12-03-2017, 02:23 PM
  2. Replies: 4
    Last Post: 05-22-2015, 02:29 AM
  3. How to have a form field based on a query?
    By rtcary in forum Access
    Replies: 8
    Last Post: 04-29-2015, 03:34 PM
  4. Query to look up value based on form field
    By c.stewart28 in forum Access
    Replies: 1
    Last Post: 04-24-2015, 09:19 AM
  5. Replies: 1
    Last Post: 11-10-2009, 03:20 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