A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Double-click to add not working



 
 
Thread Tools Display Modes
  #11  
Old August 26th, 2006, 03:14 AM posted to microsoft.public.access.forms
Gina Whipp
external usenet poster
 
Posts: 3,500
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:08 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.