If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
Double-click to add not working
Just a thought....
If ProductID is a PK then it can't contain Null or "", it must have a value os some sort. "jwr" wrote in message ... No it does not work that way either. "Access101" wrote in message ... If you were to do the following, does your double click code work: 1. Open the form in runtime 2. Immediately (before entering a value and finding it out that it is not in the list) double click the field. "Svetlana" wrote: If what you trying to do its to add a new item to the list then why do you use double click event while you could do it using NotInList event only? ProductID the name of the combobox Properties ColumnCount=3 ColumnWidths=0cm;2,54cm;0cm RowSource=SELECT tblProducts.ProductID, tblProducts.Product, tblProducts.UnitPrice FROM tblProducts ORDER BY tblProducts.Product; LimitToList=Yes. Private Sub ProductID_NotInList(NewData As String, Response As Integer) If MsgBox("You want to add the new entry " & NewData & " to list?", vbYesNo, "New Entry!") = vbYes Then Response = acDataErrAdded Dim dbs As Database Dim rst As Recordset Set dbs = CurrentDb Set rst = dbs.OpenRecordset("tblProducts") rst.AddNew rst!Product = NewData rst.Update rst.Close Else Response = acDataErrDisplay Me.ProductID.SetFocus Me.ProductID = Null End If End Sub Private Sub ProductID_AfterUpdate() Me![UnitPrice] = Me![ProductID].Column(2) End Sub |
|
Thread Tools | |
Display Modes | |
|
|