Results 1 to 5 of 5
  1. #1
    MBlondinde is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    4

    Trouble updating hidden fields while the user add a new detail record

    Hello,

    I'm pretty new to Access but know programming since a while. I have to develop a very basic form to add/update data within a table.
    My form has a combo box where the user select a record then a detail list with 1 or more entries are displayed. Only 3 fields out of 10 are displayed to the user. Modifying the record works fine. However when the user try to add a new entry, I get the following error:
    The Microsoft Access database engine cannot find a record in the table 'Product' with key matching field(s) 'ProductID'

    The interesting part is that there should not be any referential integrity problem. The ProductID is one the of hidden field. However, I'm trying to force through code the assignment of the hidden fields based on one of the detail record already displayed. I've tried putting this piece of code in the Form.BeforeInsert event or Form.Dirty. From what I see, I do assign a valid ProductID (wrote a Msgbox(Me.Recordset!ProductID) at the end of both even and the value is valid.



    Funny thing is that I don't have any Relationship defined in Access (neither Foreign Keys on the SQL Server database in the backend). I guess it's because the main query of my form is:

    Code:
    SELECT [Detail].*, [Product].ProductID, [Product].ProductDescription
    FROM [Detail] INNER JOIN [Product] ON [Detail].ProductID = [Detail].ProductID;
    I'm kind of lost here and any help would be appreciated.
    Thanks!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    It looks like you are trying to enter data , but 1 of the tables is not getting its entry , so error.
    Make sure your join allows the data entry to goto both tables.

  3. #3
    MBlondinde is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    4
    Well I'm not trying to enter data in two tables but only my "Detail" table. I'm wondering if it is the inner join on the Product table at first (Main form query) that cause the problem. However I need this join for filtering purpose initially since I need to exclude some row based on a field value in the related Product table.
    So at the end, I want to insert a new record only in the DETAIL table, not the Product; is Access trying to insert into the Product table as well simply because I have an Inner join to this table in my main query?

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Yes. Its the join. If you are entering data into 1 table , then why the join?
    remove it.

  5. #5
    MBlondinde is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    4
    The join is needed to filter the records based on specific value in the related Product table. As an example, I don't want the user to see the DETAIL record for which the PRODUCT CATEGORY = 'A'. Thus I'm filtering the initial query using the JOIN and WHERE clause which I forgot to add in my initial post.

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

Similar Threads

  1. Master\Detail Only Show Last Detail Record
    By jamies in forum Queries
    Replies: 2
    Last Post: 04-14-2014, 01:25 PM
  2. IFF record not in list allow user to enter fields
    By gg091869 in forum Programming
    Replies: 4
    Last Post: 10-04-2013, 04:19 PM
  3. Replies: 2
    Last Post: 03-06-2013, 11:37 PM
  4. Clearing Fields for on User Form for New Record
    By dccjr in forum Programming
    Replies: 1
    Last Post: 01-31-2013, 06:40 PM
  5. Trouble with updating/populating
    By eww in forum Forms
    Replies: 3
    Last Post: 08-25-2010, 07:04 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