Results 1 to 3 of 3
  1. #1
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393

    retrieving data from other tables in combo and entering it into a different table

    I have attached a simplified version of my database for an example



    frmInspections is where my problem lies at this time, if you add a new inspection (or edit an existing one) the data being entered in tblInspections is recorded correctly

    However if you select a client or an inspector then it is also adding this data again to the respective tables ie tblClients and tblInspectors

    what am I coding wrong so that it does not get re-entered as a duplicate in these tables and just the foreign key is entered into the correct table?

    Thanks

    Attachment 5009

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If I understand correctly, purpose of this form/subform is to create a new inspection and select equipment for that inspection.

    The RecordSources for the forms are incorrect and controls are bound to wrong fields.

    The RecordSource for the main form just needs to be to tblInspections, no table joins required.

    Then the ClientName and InspectorName comboboxes should be bound to the ID fields of tblInspections.

    The Equipment combobox on the subform should be a multi-column combobox. Primary key for tblEquipment is EquipmentID. This is the value that should be saved to tblEquipmentInspectionJunction. That, or change the primary key to EquipmentNo.
    Name - cboEquipment
    RowSource - SELECT tblEquipment.EquipmentID, tblEquipment.EquipmentNo, tblEquipment.Description FROM tblEquipment;
    ColumnCount - 3
    ColumnWidths - 0";.5";1"
    BoundColumn - 1
    ControlSource - EquipmentID

    Two options for getting the Description on the subform:
    1.
    The subform RecordSource just tblEquipmentInspectionJunction.
    Then the Description combobox should just be an unbound textbox with ControlSource: =cboEquipment.Column(2)
    This might be exhibit a data refresh delay on the form.
    2.
    The subform RecordSource would be:
    SELECT tblEquipmentInspectionJunction.*, tblEquipment.Description
    FROM tblEquipmentInspectionJunction LEFT JOIN tblEquipment ON tblEquipmentInspectionJunction.EquipmentID = tblEquipment.EquipmentID;
    Then the Description would be bound to the Description field. I did not think field would be editable but it is allowing edit. So set Locked Yes and TabStop No.
    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.

  3. #3
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393
    The RecordSources for the forms are incorrect and controls are bound to wrong fields.

    The RecordSource for the main form just needs to be to tblInspections, no table joins required.

    Then the ClientName and InspectorName comboboxes should be bound to the ID fields of tblInspections.


    Thanks June7 I knew it was simple but I couldn't figure it out, this is exactly what I was after

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

Similar Threads

  1. Replies: 1
    Last Post: 05-17-2011, 05:19 AM
  2. Replies: 2
    Last Post: 03-29-2011, 01:26 PM
  3. Entering data in forms with lookup tables
    By gretsch in forum Forms
    Replies: 1
    Last Post: 11-16-2010, 11:44 AM
  4. Retrieving data on my website
    By kattys in forum Access
    Replies: 1
    Last Post: 04-27-2010, 05:02 PM
  5. Replies: 0
    Last Post: 03-15-2010, 02:38 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