Results 1 to 7 of 7
  1. #1
    d9pierce1 is offline Expert
    Windows 10 Access 2019
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776

    Insert Into Statement with Where????

    Person.zip

    HI all,
    I am terrible at Where statements!


    I have attached db, opens to form

    Really small db sample, ruff! Just a sample...

    I am trying to get an after update event to put the PersonID into the tblPerson , field "SpouceID" where the Combo = PersonID of that combo.
    I have been at this most of the day and just cant put it together.... Its sort of like a reverse action.
    I really just want to put the PersonID from the main form, into the table in the field SpouceID of the person that is in the combo.
    This should not be that hard but boy can i make it that way....


    Could I get some assistance with this please!
    Thanks
    Dave

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    I think you need to use an update instead of an insert; you need to explain a bit better your intentions as the combo is already bound to the SpouseId field.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    d9pierce1 is offline Expert
    Windows 10 Access 2019
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Greetings Vlad,
    My intentions with this is yes, the combo is bound to the current reccord on the form in field spouceID. I want to take the personID on the form into the record that holds the
    Combo's PersonID. So When I add to the combo, it would also add the reverse to the persons ID in the combo.

    If I am on record 1 and I select record 7 from the combo, it puts 7 in the record 1 "SpouseID field. I want it to also add to Record 1 in Record 7's SpouseID field.
    And so on with others.
    Hope this helps!

    Thanks
    Dave

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    CurrentDb.Execute "UPDATE tblPerson SET SpouseID = " & Me.PersonID & " WHERE PersonID = " & Me.CboSpouseName
    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.

  5. #5
    d9pierce1 is offline Expert
    Windows 10 Access 2019
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Thank you June7
    I am so bad with these where conditions and I should have known the SET. I have no idea how you all remember all of these things!
    Amazing
    Dave

  6. #6
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Create a basic query of the type you want in the query editor.
    Look at the general syntax of SQL it generates and then bit by bit modify it until you break it.
    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 ↓↓

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by d9pierce1 View Post
    Thank you June7
    I am so bad with these where conditions and I should have known the SET. I have no idea how you all remember all of these things!
    Amazing
    Dave
    Of course then, there is always Google.

    https://support.microsoft.com/en-us/...9-35e5ee1e0514

    Though you do have to go to the bottom to see the sql version. However creating in design view, then copying sql view is always a good start for me.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Replies: 7
    Last Post: 05-10-2019, 10:40 PM
  2. Insert INTO SQL Statement
    By tecknologikal in forum Programming
    Replies: 3
    Last Post: 02-12-2019, 09:31 PM
  3. INSERT INTO statement
    By berderder in forum Programming
    Replies: 4
    Last Post: 06-03-2016, 06:00 PM
  4. INSERT statement
    By GraeagleBill in forum Programming
    Replies: 2
    Last Post: 03-29-2013, 12:53 PM
  5. Insert statement
    By crowegreg in forum Programming
    Replies: 2
    Last Post: 08-19-2011, 02: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