Results 1 to 7 of 7
  1. #1
    tmbartlett is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2021
    Posts
    4

    Used a button to add to a look up field how do I auto-fill the field with the new data

    I have a form - Form1 that has a lookup field of names. If the name you are looking for isn't there I have an add name button that will open the name form in data entry mode to enter the new name. On the name form I have a close button. Once that is closed you are back at Form1. I want the name field to be automatically filled with the name you just entered without having to look it up again. Is that possible?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    I have a form - Form1 that has a lookup field of names.
    Do you mean that the form has a combo box? The I would use the "Not In List" event of the combo box to handle a new entry.

    As an alternative, you may find the video at this link helpful.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,933
    I have used the Not In List even in the past?
    https://docs.microsoft.com/en-us/off...obox.notinlist
    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

  4. #4
    tmbartlett is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2021
    Posts
    4
    Yes this was very helpful. I haven't used Access in about 14 years, so some of the stuff I was doing was the old way. Exactly what you described in your video. I was getting proficient at writing code back then, but I am definitely rusty and Access has changed a lot. I am also going to watch your video on "I'm not in list". Thank you very much.

  5. #5
    tmbartlett is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2021
    Posts
    4
    Next question: After I add the name in the name form, how do I get it to automatically fill that field in Form1. So if I am on Form1 and I want to add Mary and Mary is not in the list. I hit the edit list little icon, Name form comes up and I add Mary and when I close that I want Mary to be in the name field on Form1. I know I use to write a short code, or it was in one of the built in macros, I just can't seem to remember enough details to find it. Thank you.

  6. #6
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    In the unload event of your name form check to see if Form1 is open (https://social.msdn.microsoft.com/Fo...orum=accessdev) then simply put the new name in the control:
    Code:
    Forms!Form1!txtFirstName=Me.txtName 'txtName is the name of the control on your Name form
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  7. #7
    tmbartlett is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2021
    Posts
    4
    Gicu, Thank you. That worked perfectly.

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

Similar Threads

  1. Replies: 3
    Last Post: 06-14-2020, 02:32 PM
  2. Replies: 5
    Last Post: 11-27-2017, 07:09 AM
  3. Replies: 14
    Last Post: 03-15-2017, 08:33 PM
  4. Replies: 10
    Last Post: 11-21-2011, 02:56 AM
  5. Replies: 5
    Last Post: 01-20-2011, 11:36 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