Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NotInList not updating

Status
Not open for further replies.

daniels012

Technical User
Jan 19, 2005
55
US
I have a Subform that I enter products. If the Product is not there it asks if you would like to add it. When yes is pressed, it opens a form called "AddProduct". You then add the product and close the form. It takes you back to the control you entered the product in originally. Then when you go to type the new product... the message box appears again???? If I hit no on the message box... the new item appears and I can go about my business. This would be fine if I was the only one using this form.

Once I enter the new product, It will not requery or refresh. What am I missing??

I know I am green when it comes to coding... But I really need some help.
I am not sure how to send a zipped file, but I can do that if needed?

Thank You,

Michael
 
You then add the product and close the form
Just after closing the form you may add code like this:
DoEvents
Me![name of combo].RowSource = Me![name of combo].RowSource

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hello PHV,
Where would I enter this??

Here is a sample of my code 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
By the way... I cannot open in Dialog (which someone suggested)or my program locks up!

Michael
 
I think you might have things turned around. Try this:

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
               DoCmd.OpenForm "AddNewProductsFrm", acNormal, , , acFormAdd, , NewData
       Response = acDataErrAdded 
       Else
        Response = acDataErrContinue        ProductID.Undo
        DoCmd.Save
        ProductID.Requery
    End If
End Sub
Also, I think you should open the form as acDialog so that your code does not get executed until the form closes. Otherwise the Response=acDataErrAdded will get executed prior to the record being added in the form.
 
I'll try it!
Where do I put the acDialog? Also Maybe it is messing something up because I also have:

Private Sub ProductID_GotFocus()
ProductID.Undo
DoCmd.Save
ProductID.Requery
End Sub

In the Got Focus of my Control?

Thank You,
Michael
 
daniels012 said:
[blue]Where do I put the acDialog?[/blue]
Code:
[blue]DoCmd.OpenForm "AddNewProductsFrm", acNormal, , , acFormAdd, [purple][b]acDialog[/b][/purple], NewData[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top