Results 1 to 7 of 7
  1. #1
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142

    suppress the message when item not in list

    I have a txt box that is limited to the look up list, I have other ones that I simply add the item and it is added to the list. What I want to do is when clicked open a pop up form and add the category to the new item. So far simple .......... however when I click on the txt box and open the pop up form the standard message 'XXX" is not in the list, etc. appears is there a way to suppress the message? I tried Set Warnings but it still appears. Below is what I tried by modifying the code to add to list:
    Code:
    Private Sub trbItem_NotInList(NewData As String, Response As Integer)
    Dim i As Integer
        Dim Msg As String
        If NewData = "" Then Exit Sub
        Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
        Msg = Msg & "Do you want to add it?"
        i = MsgBox(Msg, vbQuestion + vbYesNo, "Item & Category List...")
        If i = vbYes Then
            DoCmd.SetWarnings False
            DoCmd.OpenForm "frmTransactionItems", acNormal, "", "", , acNormal
            DoCmd.GoToRecord acForm, "frmTransactionItems", acLast
            DoCmd.SetWarnings True
        Else
            Response = acDataErrContinue
        End If
    End Sub


  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664

    Maybe I don't understand.
    however when I click on the txt box and open the pop up form the standard message 'XXX" is not in the list, etc. appears is there a way to suppress the message?
    You created the message:
    Code:
    Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
    Try change it to some other message:
    Code:
    Msg = "Why would you want to add '" & NewData & "' to the list?." & vbCr & vbCr


    Or
    Code:
    Private Sub trbItem_NotInList(NewData As String, Response As Integer)
    Dim i As Integer
        Dim Msg As String
        If NewData = "" Then Exit Sub
        Msg = "Oops, you tried to select'" & NewData & "'and is not currently in the list." & vbCr & vbCr
        Msg = Msg & "Do you want to add it?"
        i = MsgBox(Msg, vbQuestion + vbYesNo, "Item & Category List...")
        If i = vbYes Then
            DoCmd.SetWarnings False
            DoCmd.OpenForm "frmTransactionItems", acNormal, "", "", , acNormal
            DoCmd.GoToRecord acForm, "frmTransactionItems", acLast
            DoCmd.SetWarnings True
        Else
            Response = acDataErrContinue
        End If
    End Sub


    http://www.blueclaw-db.com/access_no...ed_example.htm
    http://allenbrowne.com/ser-27.html
    http://www.fontstuff.com/access/acctut20.htm

  3. #3
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    Thanks as you can probably tell I am no expert I took the code I already have to add an item to the list which I received from this site and tried to make my own alterations consequently I may have some redundant or useless code included.

    I tried your code but I still get the same result I get my pop up and the standard information message:
    "The text you entered isn't an item in the list.not in the list."
    I am trying to suppress the standard message?
    I am sorry if I am being unclear.

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Suggest you use the same variable for yes/no, not i for one and Response for the other
    Code:
    Dim Response As Integer
    Dim Msg As String
    
    If NewData = "" Then Exit Sub
      Msg = "Oops, you tried to select'" & NewData & "'and is not currently in the list." & vbCr & vbCr
      Msg = Msg & "Do you want to add it?"
      Response = MsgBox(Msg, vbQuestion + vbYesNo, "Item & Category List...")
      If Response = vbYes Then
        DoCmd.SetWarnings False
        DoCmd.OpenForm "frmTransactionItems", acNormal, "", "", , acNormal
        DoCmd.GoToRecord acForm, "frmTransactionItems", acLast
        DoCmd.SetWarnings True
      Else
        Response = acDataErrContinue
    End If
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    I get a compile error.
    "Duplicate declaration in current scope"
    Highlights
    Dim Response As Integer

  6. #6
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    This is what I want to do:
    1. Enter an item in the form [frmBreakdown] from drop down list
    2. If the item is not in the list I want to add it to the list [tlkpItem].
    3. When the item is added I want the pop up [frmItemlist] to open at the last record
    4. I want to add a category [tlkpItemCat] to the item that has just been added
    5. Then return to the form [frmBreakdown]

  7. #7
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    Figured it out was looking at a query item and attempting to add to a table SORRY

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

Similar Threads

  1. Replies: 2
    Last Post: 07-31-2015, 02:49 PM
  2. Replies: 6
    Last Post: 11-26-2013, 09:20 AM
  3. Replies: 9
    Last Post: 02-26-2013, 10:48 AM
  4. Replies: 1
    Last Post: 03-25-2012, 01:53 PM
  5. Suppress spell check error message
    By sabre1 in forum Forms
    Replies: 1
    Last Post: 03-24-2011, 09:58 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