Results 1 to 9 of 9
  1. #1
    Phillipc1 is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2023
    Posts
    13

    Search Bar - How to add no value found pop up


    Hello All!

    I have a search bar created for my main menu form, that when searched will open up the appropriate form for that value. However, I am wanting to put in something that when a user enters in a value that is not in the database it will prompt them with a no value found pop up but also ask if they would like to create a new entry, which it will provide a yes or no button. How can I go about doing this. Screen shot of the main menu that I am wanting to add this function to for the search bar and database zipped file is attached.
    Attached Thumbnails Attached Thumbnails Main Menu.png  
    Attached Files Attached Files

  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,544
    Move the On Click event code to the After Update event.
    Change the Limit to list property of the combo to yes.
    You can then catch the attempted entry of data not in the list and question if it should be added.
    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
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    You might use something like the following in the Not In List event:
    Code:
        If MsgBox("Add '" & NewData & "' to the list?", vbYesNo) = vbYes Then        DoCmd.OpenForm FormName:="Equipment_List_Form", OpenArgs:=Me.cboSearch.Value
            DoCmd.GoToRecord , , acNewRec
            Forms!Equipment_List_Form.[Equipment #] = NewData
            Response = acDataErrContinue
        Else
            Response = acDataErrContinue
        End If
    BTW I would avoid the use of spaces and keys like "#" in the names of any object. I would perhaps use EquipementNum instead.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    Phillipc1 is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2023
    Posts
    13
    Fantastic, thank you Bob! I appreciate the catch on the "#" issue as I had thought I cleaned that up already. Granted my actual DB is much larger, so it seems like I missed it here. I will give this a try and see how it turns out.

  5. #5
    Phillipc1 is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2023
    Posts
    13
    So it looks like I am getting an error when adding the NotInList event. See attached images.
    Attached Thumbnails Attached Thumbnails Expression Error.jpg   Compile Error.jpg  

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    You put the Then portion on the same line?
    I always end with Then and put all the code that will be executed on the next lines, even one liners.

    Also no need for Else really, as you are executing that Response line regardless? I would just have it after the If block.

    You have copied Bob's code verbatim, but this site appends the second line to the first line a lot of the time.

    PITA TBH.
    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

  7. #7
    Phillipc1 is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2023
    Posts
    13
    Thank you both, I believe I have gotten it sorted out now to operate properly. The one exception which I am not too worried about is when I select no to add a value to the list, it will populate an error message and then a message reiterating the value could not be found. Not sure if there is a way to eliminate that, but either way it gets me pointed in the right direction.

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    As always, look for the syntax and examples.

    https://learn.microsoft.com/en-us/of...obox.notinlist

    Now you will need the Else portion.
    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

  9. #9
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by Phillipc1 View Post
    Thank you both, I believe I have gotten it sorted out now to operate properly. The one exception which I am not too worried about is when I select no to add a value to the list, it will populate an error message and then a message reiterating the value could not be found. Not sure if there is a way to eliminate that, but either way it gets me pointed in the right direction.
    See the example that I posted
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. ERROR: The search key was not found in any record
    By templeowls in forum Programming
    Replies: 24
    Last Post: 03-01-2021, 01:47 PM
  2. The search key was not found in any record
    By virtualprg in forum Import/Export Data
    Replies: 46
    Last Post: 08-26-2014, 10:51 AM
  3. Search key was not found in any record.
    By mgio in forum Access
    Replies: 2
    Last Post: 08-05-2014, 01:32 PM
  4. Replies: 7
    Last Post: 04-17-2013, 04:33 PM
  5. Import search key not found
    By patjivan in forum Import/Export Data
    Replies: 0
    Last Post: 12-13-2011, 12:52 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