Results 1 to 5 of 5

Thread: Datasheet view

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

    Unanswered: Datasheet view

    My subform is in datasheet view.
    It has 3 items, ProductID, Quantity, ProductPrice
    If I want to enter a new product, I start to enter the name and if it does not recognize it, it brings up a message Yes/No to enter new item. I hit yes
    It opens the form FrmAddNewProduct, I enter all info.
    I Requery then close.
    It takes me back to the form I was in with the cursor blinking.
    I hit enter and brings up the Message again. If I hit No, it will enter the data??
    How can I avoid this? If I need to I will send the form so anyone could help!

    Thank You,
    Michael
    Gotta to do some code

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    Are you opening the form FrmAddNewProduct as a dialog box? Using acDialog in the OpenForm call? If you do that then you can add a Requery to the combo box after the form closes. It would be something like:

    DoCmd.OpenForm "FrmAddNewProduct", , , , acFormAdd, acDialog
    cboProductID.Requery

    The requery does not happen until the user closes or hides the FrmAddNewProduct form. This should prevent the message from showing again.

  3. #3
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    Thank you for responding right away!!
    This is what I have now
    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 "AddNewProductsFrm", acNormal, , , acFormAdd, , NewData
    Else
    Response = acDataErrAdded
    ProductID.Undo
    DoCmd.Save
    ProductID.Requery
    End If
    End Sub

    Where should I enter the code you suggested? Do I need code in the AddNewProductsFrm ?

    Thank You
    Michael
    Gotta to do some code

  4. #4
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    Here is your code with the modifications:

    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 "AddNewProductsFrm", acNormal, , , acFormAdd, acDialog, NewData
              ProductID.Requery
         Else
              Response = acDataErrAdded
              ProductID.Undo
              DoCmd.Save
              ProductID.Requery
         End If
    End Sub

  5. #5
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    Debugger came up:
    It says I must save the current field before I can Requery??
    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
  •