Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271

    Question Unanswered: NotInList I have tried everything!!

    I have tried very hard to get this code to run. I goes fine then when I try to close my second form,FormB...it locks up?? What am I missing? I can move around on formB just fine, then when I go to close OR MOVE the form it locks up. I can send the file if needed to see what I am missing!

    Please help anyone!!!

    Here is the code:

    Form A

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

    Form B

    Private Sub Form_Load()
    If Not IsNull(Me.OpenArgs) Then
    Me!Customer = Me.OpenArgs
    End If
    End Sub
    Gotta to do some code

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Attach the DB

  3. #3
    Join Date
    Feb 2004
    Posts
    22
    Try putting Response = acDataErrAdded after the DoCmd.

    Jack

  4. #4
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    when I use notinlist i do it this way

    if msgbox("Not in list. Add?",vbyesno,"Add?") = vbyes then

    'add the item using sql insert into or dao

    'then requery the combobox
    mycombobox.requery

    end if
    Dale Houston, TX

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    also take a look at my trials and tribulations at http://www.dbforums.com/t989642.html

    izy
    currently using SS 2008R2

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

    Exclamation Izy

    I have looked all through your NotInList forum in the past. In your example you are just entering an item in one field. I am trying to fill in information on the newly opened form and it then locks up?

    I am not sure of the problem I am having. Why it locks up? I can get all the way to the form and I enter data in the new form that is open... Then it locks up and will not close. I have no idea why?
    Gotta to do some code

  7. #7
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    well that was my first play with not in list and everything was completely banana-shaped without the .undo

    the m$dn site reference that someone posted in the other link also included sample code that had a .undo equivalent.

    i don't see .undo in your code, so i wonder if you are looping endlessly thru the _notinlist

    put a breakpoint in the _notinlist code and see if you keep looping

    izy
    currently using SS 2008R2

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

    Tried it!

    I did it your way. It would append the record just perfectly.

    The only issue is I want it to add more than just the one item. When I add a company I add Address, City, State, Phone, etc. I would like to get the other form open to edit this information.

    Maybe I could do it your way then hit another button to enter it's information. Or write code that would take me to the new form with currently added record.
    Any Ideas?

    I tried to add the .undo with no luck.
    Gotta to do some code

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

    Smile Izy

    When I use your method using the SQL insert, it does not add it as the last record. I do not have an auto number in my first column?
    Gotta to do some code

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

    Anyone

    Anyone know why these things are not working?
    Gotta to do some code

  11. #11
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Why are you using

    Response = acDataErrAdded

    ?

    You use that if you want the add the new value DIRECTLY INTO THE COMBOBOX.

    You are not doing that.

    You are adding the value using a second form.

    So, regardless of the user's response to your messagebox, you want to use acDataErrContinue.

    You may have another problem here, but let's get this one out of the way first.

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

    No Luck

    Thank you for responding so quickly!

    When I did as you said (taking out the) acDataErrAdded it would no longer send the info to the second form. It is still locking up on me????

    Surf
    Gotta to do some code

  13. #13
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    What happens if you don't open up the second form as acDialog ?

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

    Nope

    It just sits there? Locks up. It won't even go to the 2nd form?

    Help
    Gotta to do some code

  15. #15
    Join Date
    Feb 2004
    Posts
    22
    I copied and pasted the original code you posted into the NotInList event of the Orders form, and the OnLoad event of the Customers form of the Northwind database. It worked perfectly when I typed in a CompanyName that was not on the list. I do not know why the form you are calling locks up. Are you making sure that you are filling in all REQUIRED fields?

    Jack

Posting Permissions

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