Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271

    Question Unanswered: Adding new data and returning to form that doesn't update.

    I USE THE NOTINLIST TO GO TO A SECOND FORM. I GET EVERYTHING ENTERED, THEN WHEN IT TAKES ME BACK TO THE ORIGINAL FORM, IT SAYS THE DATA IS NOT THERE.

    CODE IS BELOW.



    Private Sub BillToID_NotInList(NewData As String, Response As Integer)
    Response = acDataErrContinue
    If MsgBox("The Company " & NewData & " you entered, does not exist yet." & vbCrLf & vbCrLf & "Do You wish to add it?", vbQuestion + vbYesNo) = vbYes Then
    DoCmd.OpenForm "FrmEnterCompany", acNormal, , , acFormAdd, , NewData
    Else
    Response = acDataErrAdded
    BillToID.Undo
    BillToID.Requery
    End If
    End Sub

    ANY HELP WOULD BE GREATLY APPRECIATED
    Gotta to do some code

  2. #2
    Join Date
    Feb 2004
    Posts
    142
    In the second form save the data then requery the first form's combobox before closing the second form.
    KC

  3. #3
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271

    Little Help

    Should I do that with a button. Say... on click save data, then requery the BillToID on form 1, then close?????

    Am I close?
    Gotta to do some code

  4. #4
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271

    Nope

    That did not work!! I guess I am not familiar with the proper code possibly.
    Gotta to do some code

  5. #5
    Join Date
    Sep 2003
    Location
    Indonesia
    Posts
    2
    I think you don't need a button to update your form1's listbox. Just put your refreshment code in form2's close event.
    Usually I use this :

    Private Sub Form2_Close()
    me.refresh
    Forms!Form1!{your listbox's name}.Requery
    End Sub

    and if that code doesn't work, I add this :

    Private Sub Form1_GotFocus()
    Me.{your listbox's name}.Requery
    End Sub

  6. #6
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271

    Well

    In your first example I cannot requery because the data that I started to enter has not been saved. I really need to find code that will erase or undo what I have done then requery.

    In the second example I cannot use got focus because I am using notinlist. If I try to requery when I got focus it gives me an error.

    Thank You though!
    Gotta to do some code

  7. #7
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    When you open the second form, make sure to open it as a Dialog. In the sixth parameter, WindowMode, set it to acDialog. When you open a form as a dialog, the user is only allowed to work in the opened form until it is closed. The other nice thing is when you open the form, the code that called the form is suspended until the second form is closed. So if you put something like :

    DoCmd.OpenForm "frmEditorComponentOne", acNormal, , , acFormAdd, acDialog
    Me.sfrmEditorComponent.Form.Requery

    I use this to open a form to add a new component, then when the user closes the form the next line is executed and that requeries all my components and the new one appears.

  8. #8
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271

    OK

    I have tried to use the acDialog. When I do it the 2nd form just locks up on me!!! So when I took the acDialog out, everything has been fine till the issue listed above
    Gotta to do some code

  9. #9
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271

    Red face Save

    How can I save, requery, Undo using code?
    Gotta to do some code

  10. #10
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    I am not sure why you form locks up with acDialog. There has to be some other code that is interfering. But if you want to make sure the new record in your second form is saved then try.

    DoCmd.RunCommand acCmdSaveRecord

    Or moving to the next rcord will save the current record.

  11. #11
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271

    Huh

    I will have to try this?
    Gotta to do some code

Posting Permissions

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