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

    Unanswered: After not in list

    I have an ordering form we use at work. I cannot get the Ordering form to requery or accept the new product after it has been entered.

    Here is the code:
    Private Sub ProductID_NotInList(NewData As String, Response As Integer)
    If MsgBox("The Product " & NewData & " you entered, does not exist yet." & vbCrLf & vbCrLf & "Do you wish to add it?", _
    vbQuestion + vbYesNo) = vbYes Then
    Response = acDataErrContinue
    DoCmd.OpenForm "FrmAddNewProducts", acNormal, , , acFormAdd, , NewData
    Else
    Response = acDataErrAdded
    ProductID.Undo
    DoCmd.Save
    ProductID.Requery
    End If
    End Sub


    As soon as I close the Form which I add new products It takes me to my Ordering form and if I try to enter the info again it runs me through the same Msgbox all over again.
    I know it just needs to Save or Requery!! It's not though!

    Any Ideas?
    Michael
    Gotta to do some code

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi Michael

    Looks to me you've got your repsonses mixed up - acDataErrAdded should be after vbYes not no. Got to admit, my AXP Help at home isn't comprehensive so I can't check but I think that's the problem.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    Still the same problems!

    Thank You though!

    As you can see it is frustrating me!
    Michael
    Gotta to do some code

  4. #4
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    Should I enter code in the exit of the other form that would remove what is in the current control, requery, then save? Can you do this to another form while your closing the current form?
    If any of this is possible, I would really appreciate the assistance as to what code I should write.

    thanks in advance!
    Michael
    Gotta to do some code

  5. #5
    Join Date
    Sep 2003
    Posts
    228
    I posted my solution to what you are doing in this thread:

    http://www.dbforums.com/t998346.html

    I thought I was doing to much to get the entry into the combo box. It works though...

    I was just looking for a better solution.

  6. #6
    Join Date
    Sep 2003
    Posts
    228
    OK, this seems like the "best" solution:
    If it's not in the list but you want it to be. Inside the notinlist event just blast the data you want into the table using an update of any kind.

    Private Sub HGS_Model_NotInList(NewData As String, Response As Integer)
    Dim strSelect As String
    Dim strFrom As String
    Dim strWhere As String
    Dim strOrderBy As String
    Dim strSQL As String
    Dim criteria As String

    Const msg1 = "The data you entered is not currently in the list."
    Const msg2 = "Would you like to add it?"
    Const title = "New Entry?"
    Const NL = vbCrLf & vbCrLf

    criteria = "[FD Project] = """ & Me.FD_Project & """"

    If MsgBox(msg1 & NL & msg2, vbQuestion + vbYesNo, title) = vbYes Then
    strSQL = "UPDATE [tblPrograms] SET [HGS Model] = """ & NewData & """ WHERE [FD Project] = """ & Me.FD_Project & """"
    DoCmd.SetWarnings False
    DoCmd.RunSQL strSQL
    DoCmd.SetWarnings True
    Response = acDataErrAdded ' confirm record added
    Else
    Me.[HGS Model].Undo ' clear the entry in the combobox
    Response = acDataErrContinue ' confirm the record is not allowed
    End If
    End Sub

  7. #7
    Join Date
    Sep 2003
    Posts
    228
    I may have misunderstood your problem. I apologize if I have. At least I got my problem worked out, right?

  8. #8
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    Thank You for you quick response ottomatic!


    I think this would work if I just had 1 item to replace.
    I need to go to the other form enter the NEW Product, NEW supplier (possibly), enter prices, enter order amount. Then, I need to exit the form and take me back to the original form and enter the new Product I just entered.

    Anyone else??
    Michael
    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
  •