Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple notinlist and requery of cbo (acc97-sr2)

    This part gets caught in a loop of not accepting or requerying, even though the second form does add the entry into the table.

    Private Sub cbo_form1_NotInList(NewData As String, Response As Integer)
    Dim strMsg As String

    strMsg = "'" & NewData & "' is not in the list.'"
    strMsg = strMsg & "Would you like to add it?"

    If MsgBox(strMsg, vbYesNo) = vbNo Then
    Response = acDataErrDisplay

    Else
    ' Place new form here for complete entry
    DoCmd.OpenForm "frm_frm2"

    End If

    End Sub

    The seconf form (frm_Form2) data entry only has this even on a close button

    Private Sub cmd_frmClose_Click()
    On Error GoTo Err_cmd_frmClose_Click


    DoCmd.Close

    Exit_cmd_frmClose_Click:
    Exit Sub

    Err_cmd_frmClose_Click:
    MsgBox Err.Description
    Resume Exit_cmd_frmClose_Click

    End Sub

    Then I get back to my main form and requery on the after update event
    Private Sub cbo_Field1_AfterUpdate()
    Me!cbo_Fieldname.Requery
    End Sub

    What a way to start a vacation
    <img src=/S/toilet.gif border=0 alt=toilet width=24 height=26>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Simple notinlist and requery of cbo (acc97-sr2)

    Your code will run on after you open frm_frm2. You should open this form as a dialog, then the code in the main form will wait until the user has closed frm_frm2. Use

    DoCmd.OpenForm FormName:="frm_frm2", WindowMode:=acDialog

    or

    DoCmd.OpenForm "frm_frm2", , , , , acDialog

  3. #3
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Simple notinlist and requery of cbo (acc97-sr2)

    I'm sick of this.
    Somebody just point me to a post where a new record is added'
    and the form is requeried.
    I'm sure it's been done hundreds of times.

    Better yet, if theres any sample dbs with the code, so much the better.
    ANY assistance appreciated.
    Thanks, <img src=/S/cooked.gif border=0 alt=cooked width=50 height=46>

  4. #4
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Simple notinlist and requery of cbo (acc97-sr2)

    One thing that Hans forgot, is after you open the form in dialog mode, you need to add

    Response = acDataErrAdded

    Also, you can search the Lounge for NotInList and come up with more than 100 posts dealing with NotInList stuff.

    Just click the Search link at the top of the page.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Simple notinlist and requery of cbo (acc97-sr2)

    Bryan pointed you in the right direction. Here are two specific posts that deal with this: <post#=146637>post 146637</post#> and <post#=36545>post 36545</post#>.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •