Pulling new data into a popup form

hunterfan48

Registered User.
Local time
Today, 03:59
Joined
Aug 17, 2008
Messages
436
Hi guys,
I'm working on the Boutique Fudge database from the Missing Manual: Access 2007 book. In chapter 17, they are teaching me how to have code in the 'on not in list' event to have another form popup that allows me to enter info in it.

I understand the code that gets me to open the other form. However, I'm confused as to pulling in the name I just typed in the combo box to having that pull in to this new popup form.

Here's the code I'm looking at.

Code:
' Open the AddProduct form, with three additional arguments.
DoCmd.OpenForm "AddProduct", , , , , acDialog, NewData
 
' Cancel the edit. That's because you need to refresh the list
' before you can select the new product.
ProductID.Undo
' Refresh the list.
ProductID.Requery
' Now find the ProductID for the newly added item using DLookup.
ProductID = DLookup("ID", "Products", "ProductName='" & NewData & "'")
' Refresh the price.
ProductID_Change
 
End Sub

I think I'm getting mixed up in the DLookup section.

What's this part all about?

ProductName='" & NewData & "'")

Maybe if I can figure that out...the rest will come to me.

Thanks,
Brady
 
Here is some more code that I've been working on. I've posted my code (in the 1st box) and the sample code (in the 2nd box) to show what I'm trying to do. I can't get mine to autofill a new number in my ID field as well as transferring the new name into the field.
Code:
Private Sub CustomerID_NotInList(NewData As String, Response As Integer)
 
DoCmd.OpenForm "entercustomer", , , , , acDialog, NewData
CustomerID.Undo
CustomerID.Requery
CustomerID = DLookup("ID", "tblCustomers", "ID='" & NewData & "'")
 
End Sub

Sample Database code (Actually works)
Code:
 ' Open the AddProduct form, with three additional arguments.
        DoCmd.OpenForm "AddProduct", , , , , acDialog, NewData
 
        ' Cancel the edit. That's because you need to refresh the list
        ' before you can select the new product.
        ProductID.Undo
        ' Refresh the list.
        ProductID.Requery
        ' Now find the ProductID for the newly added item using DLookup.
        ProductID = DLookup("ID", "Products", "ProductName='" & NewData & "'")
 

Users who are viewing this thread

Back
Top Bottom