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

    Not in list action

    I want to have a "not in list" message box Yes/No that if Yes is clicked the form closes and a new one opens, if No is clicked it goes back to the form.

    PLEASE tell me what is wrong with this code:

    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, "Company List...")
    If i = vbYes Then
    DoCmd.Close acForm, "frmContacts"
    DoCmd.OpenForm "frmContractors", acNormal, "", "", , acNormal
    DoCmd.GoToRecord acForm, "frmContractors", acNewRec
    Else
    Response = acDataErrContinue


    End If

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    IF this code is in frmContacts ,then you close frmContacts,
    then the code vanishes with the form.
    Dont close the form, just open frmContractors.

    Im not sure what the 'not in list' means.

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Basically, I cannot see where your code inserts new data into a table.
    See this site for code example: http://www.databasedev.co.uk/not_in_list.html
    or http://allenbrowne.com/ser-27.html

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    If it helps, here is some code that came from one of my DB's. What I opt to do is open another form in Data Entry mode. I set the Data Entry mode in the other form's properties and save it. Also, the other form is pop up/modal.

    Code:
    Response = acDataErrContinue
    
    Dim intMsg As Integer
    
    intMsg = MsgBox("That Species does not exist within the list." & vbCrLf & _
                    "Do you want to add a new species?", vbYesNo + vbQuestion + vbDefaultButton2, "Item Not Found")
                    
    If intMsg = vbYes Then
        Me.cmbSpecies.Value = ""
        If Me.Dirty Then Me.Dirty = False
        DoCmd.OpenForm "frmSpeciesEntry"
    Else
        Me.cmbSpecies.Value = ""
    End If

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

Similar Threads

  1. sendkey action
    By sdel_nevo in forum Programming
    Replies: 9
    Last Post: 03-25-2015, 10:33 AM
  2. Can't run this action???
    By wwg77 in forum Programming
    Replies: 2
    Last Post: 02-02-2011, 03:22 PM
  3. Macro Action
    By Bakar in forum Forms
    Replies: 1
    Last Post: 01-05-2011, 12:38 PM
  4. PrintOut action
    By svcghost in forum Programming
    Replies: 11
    Last Post: 10-05-2010, 05:13 PM
  5. No action button
    By dlewicki in forum Forms
    Replies: 6
    Last Post: 12-02-2009, 12:58 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