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
  #1  
Old August 24th, 2006, 03:51 AM posted to microsoft.public.access.forms
jwr
external usenet poster
 
Posts: 21
Default Double-click to add not working

I have a subform that contains a combo box. ProductID is the record source.
Below is the code behind this field. I have another drop down list with
double click that does work and I do not see anything different.

Your assistance is appreciated.


Private Sub ProductID_NotInList(NewData As String, Response As Integer)
MsgBox "Double-click this field to add an entry to the list."
Response = acDataErrContinue
End Sub
Private Sub ProductID_AfterUpdate()
Me![UnitPrice] = Me![ProductID].Column(2)
End Sub
Private Sub ProductID_DblClick(Cancel As Integer)
On Error GoTo Err_ProductID_DblClick
Dim lngProductID As Long

If IsNull(Me![ProductID]) Then
Me![ProductID].Text = ""
Else
lngProductID = Me![ProductID]
Me![ProductID] = Null
End If
DoCmd.OpenForm "Products", , , , , acdialog, "GotoNew"
Me![ProductID].Requery
If lngProductID 0 Then Me![ProductID] = lngProductID

Exit_ProductID_DblClick:
Exit Sub

Err_ProductID_DblClick:
MsgBox Err.Description
Resume Exit_ProductID_DblClick
End Sub


  #2  
Old August 24th, 2006, 02:20 PM posted to microsoft.public.access.forms
Barry Gilbert
external usenet poster
 
Posts: 379
Default Double-click to add not working

When you say that it doesn't work, do you mean that the event isn't firing or
is there some other aspect of it that doesn't work. If you put a break on
your first line of code, does it stop execution there?

Barry

"jwr" wrote:

I have a subform that contains a combo box. ProductID is the record source.
Below is the code behind this field. I have another drop down list with
double click that does work and I do not see anything different.

Your assistance is appreciated.


Private Sub ProductID_NotInList(NewData As String, Response As Integer)
MsgBox "Double-click this field to add an entry to the list."
Response = acDataErrContinue
End Sub
Private Sub ProductID_AfterUpdate()
Me![UnitPrice] = Me![ProductID].Column(2)
End Sub
Private Sub ProductID_DblClick(Cancel As Integer)
On Error GoTo Err_ProductID_DblClick
Dim lngProductID As Long

If IsNull(Me![ProductID]) Then
Me![ProductID].Text = ""
Else
lngProductID = Me![ProductID]
Me![ProductID] = Null
End If
DoCmd.OpenForm "Products", , , , , acdialog, "GotoNew"
Me![ProductID].Requery
If lngProductID 0 Then Me![ProductID] = lngProductID

Exit_ProductID_DblClick:
Exit Sub

Err_ProductID_DblClick:
MsgBox Err.Description
Resume Exit_ProductID_DblClick
End Sub



  #3  
Old August 24th, 2006, 04:09 PM posted to microsoft.public.access.forms
jwr
external usenet poster
 
Posts: 21
Default Double-click to add not working

Sorry, I did not explain fully.

If my product is not in the drop down list, when I type the name, I get a
pop-up form that says "Double Click on this to add." Double clicking does
nothing. No errors, nothing.

I am not real knowledgeable in code. What do you mean, "If you put a break
on your first line of code, does it stop execution there?"

Thanks

"Barry Gilbert" wrote in message
...
When you say that it doesn't work, do you mean that the event isn't firing
or
is there some other aspect of it that doesn't work. If you put a break on
your first line of code, does it stop execution there?

Barry

"jwr" wrote:

I have a subform that contains a combo box. ProductID is the record
source.
Below is the code behind this field. I have another drop down list with
double click that does work and I do not see anything different.

Your assistance is appreciated.


Private Sub ProductID_NotInList(NewData As String, Response As Integer)
MsgBox "Double-click this field to add an entry to the list."
Response = acDataErrContinue
End Sub
Private Sub ProductID_AfterUpdate()
Me![UnitPrice] = Me![ProductID].Column(2)
End Sub
Private Sub ProductID_DblClick(Cancel As Integer)
On Error GoTo Err_ProductID_DblClick
Dim lngProductID As Long

If IsNull(Me![ProductID]) Then
Me![ProductID].Text = ""
Else
lngProductID = Me![ProductID]
Me![ProductID] = Null
End If
DoCmd.OpenForm "Products", , , , , acdialog, "GotoNew"
Me![ProductID].Requery
If lngProductID 0 Then Me![ProductID] = lngProductID

Exit_ProductID_DblClick:
Exit Sub

Err_ProductID_DblClick:
MsgBox Err.Description
Resume Exit_ProductID_DblClick
End Sub





  #4  
Old August 24th, 2006, 04:35 PM posted to microsoft.public.access.forms
Barry Gilbert
external usenet poster
 
Posts: 379
Default Double-click to add not working

In your code, inside the ProductId_DblClick routine, put your cursor on the
line that says:
If IsNull(Me![ProductID]) Then

and click F9. This will change the line's color, meaning it has a break.
When (if) the code's execution reaches this line, it will stop. You can then
click F8 to step through each line of code to try to see where it's failing.

Barry


"jwr" wrote:

Sorry, I did not explain fully.

If my product is not in the drop down list, when I type the name, I get a
pop-up form that says "Double Click on this to add." Double clicking does
nothing. No errors, nothing.

I am not real knowledgeable in code. What do you mean, "If you put a break
on your first line of code, does it stop execution there?"

Thanks

"Barry Gilbert" wrote in message
...
When you say that it doesn't work, do you mean that the event isn't firing
or
is there some other aspect of it that doesn't work. If you put a break on
your first line of code, does it stop execution there?

Barry

"jwr" wrote:

I have a subform that contains a combo box. ProductID is the record
source.
Below is the code behind this field. I have another drop down list with
double click that does work and I do not see anything different.

Your assistance is appreciated.


Private Sub ProductID_NotInList(NewData As String, Response As Integer)
MsgBox "Double-click this field to add an entry to the list."
Response = acDataErrContinue
End Sub
Private Sub ProductID_AfterUpdate()
Me![UnitPrice] = Me![ProductID].Column(2)
End Sub
Private Sub ProductID_DblClick(Cancel As Integer)
On Error GoTo Err_ProductID_DblClick
Dim lngProductID As Long

If IsNull(Me![ProductID]) Then
Me![ProductID].Text = ""
Else
lngProductID = Me![ProductID]
Me![ProductID] = Null
End If
DoCmd.OpenForm "Products", , , , , acdialog, "GotoNew"
Me![ProductID].Requery
If lngProductID 0 Then Me![ProductID] = lngProductID

Exit_ProductID_DblClick:
Exit Sub

Err_ProductID_DblClick:
MsgBox Err.Description
Resume Exit_ProductID_DblClick
End Sub






  #5  
Old August 24th, 2006, 08:59 PM posted to microsoft.public.access.forms
jwr
external usenet poster
 
Posts: 21
Default Double-click to add not working


I put in the break, tried to run the routine, got message box to double
click, but it is not working. This takes me to the Code. The line that
says:

If IsNull(Me![ProductID]) Then
is highlighted with yellow (over the color that it changed to with
F9).

I press F8, then the line that reads:
Me![ProductID].Text = ""
is highlighted yellow.

I press F8 again, and
MsgBox Err.Description
is highlighted yellow.

Now I do not know what I should do next.

Thank you.


"Barry Gilbert" wrote in message
...
In your code, inside the ProductId_DblClick routine, put your cursor on
the
line that says:
If IsNull(Me![ProductID]) Then

and click F9. This will change the line's color, meaning it has a break.
When (if) the code's execution reaches this line, it will stop. You can
then
click F8 to step through each line of code to try to see where it's
failing.

Barry


"jwr" wrote:

Sorry, I did not explain fully.

If my product is not in the drop down list, when I type the name, I get a
pop-up form that says "Double Click on this to add." Double clicking
does
nothing. No errors, nothing.

I am not real knowledgeable in code. What do you mean, "If you put a
break
on your first line of code, does it stop execution there?"

Thanks

"Barry Gilbert" wrote in message
...
When you say that it doesn't work, do you mean that the event isn't
firing
or
is there some other aspect of it that doesn't work. If you put a break
on
your first line of code, does it stop execution there?

Barry

"jwr" wrote:

I have a subform that contains a combo box. ProductID is the record
source.
Below is the code behind this field. I have another drop down list
with
double click that does work and I do not see anything different.

Your assistance is appreciated.


Private Sub ProductID_NotInList(NewData As String, Response As
Integer)
MsgBox "Double-click this field to add an entry to the list."
Response = acDataErrContinue
End Sub
Private Sub ProductID_AfterUpdate()
Me![UnitPrice] = Me![ProductID].Column(2)
End Sub
Private Sub ProductID_DblClick(Cancel As Integer)
On Error GoTo Err_ProductID_DblClick
Dim lngProductID As Long

If IsNull(Me![ProductID]) Then
Me![ProductID].Text = ""
Else
lngProductID = Me![ProductID]
Me![ProductID] = Null
End If
DoCmd.OpenForm "Products", , , , , acdialog, "GotoNew"
Me![ProductID].Requery
If lngProductID 0 Then Me![ProductID] = lngProductID

Exit_ProductID_DblClick:
Exit Sub

Err_ProductID_DblClick:
MsgBox Err.Description
Resume Exit_ProductID_DblClick
End Sub








  #6  
Old August 24th, 2006, 10:32 PM posted to microsoft.public.access.forms
Barry Gilbert
external usenet poster
 
Posts: 379
Default Double-click to add not working

This tells us that the Me![ProductID].Text = "" statement is invalid. Try
removing the ".text" portion so that it reads:
Me![ProductId]=""

Barry

"jwr" wrote:


I put in the break, tried to run the routine, got message box to double
click, but it is not working. This takes me to the Code. The line that
says:

If IsNull(Me![ProductID]) Then
is highlighted with yellow (over the color that it changed to with
F9).

I press F8, then the line that reads:
Me![ProductID].Text = ""
is highlighted yellow.

I press F8 again, and
MsgBox Err.Description
is highlighted yellow.

Now I do not know what I should do next.

Thank you.


"Barry Gilbert" wrote in message
...
In your code, inside the ProductId_DblClick routine, put your cursor on
the
line that says:
If IsNull(Me![ProductID]) Then

and click F9. This will change the line's color, meaning it has a break.
When (if) the code's execution reaches this line, it will stop. You can
then
click F8 to step through each line of code to try to see where it's
failing.

Barry


"jwr" wrote:

Sorry, I did not explain fully.

If my product is not in the drop down list, when I type the name, I get a
pop-up form that says "Double Click on this to add." Double clicking
does
nothing. No errors, nothing.

I am not real knowledgeable in code. What do you mean, "If you put a
break
on your first line of code, does it stop execution there?"

Thanks

"Barry Gilbert" wrote in message
...
When you say that it doesn't work, do you mean that the event isn't
firing
or
is there some other aspect of it that doesn't work. If you put a break
on
your first line of code, does it stop execution there?

Barry

"jwr" wrote:

I have a subform that contains a combo box. ProductID is the record
source.
Below is the code behind this field. I have another drop down list
with
double click that does work and I do not see anything different.

Your assistance is appreciated.


Private Sub ProductID_NotInList(NewData As String, Response As
Integer)
MsgBox "Double-click this field to add an entry to the list."
Response = acDataErrContinue
End Sub
Private Sub ProductID_AfterUpdate()
Me![UnitPrice] = Me![ProductID].Column(2)
End Sub
Private Sub ProductID_DblClick(Cancel As Integer)
On Error GoTo Err_ProductID_DblClick
Dim lngProductID As Long

If IsNull(Me![ProductID]) Then
Me![ProductID].Text = ""
Else
lngProductID = Me![ProductID]
Me![ProductID] = Null
End If
DoCmd.OpenForm "Products", , , , , acdialog, "GotoNew"
Me![ProductID].Requery
If lngProductID 0 Then Me![ProductID] = lngProductID

Exit_ProductID_DblClick:
Exit Sub

Err_ProductID_DblClick:
MsgBox Err.Description
Resume Exit_ProductID_DblClick
End Sub









  #7  
Old August 24th, 2006, 11:59 PM posted to microsoft.public.access.forms
jwr
external usenet poster
 
Posts: 21
Default Double-click to add not working

I removed "text". Still does not work. If I do make a selection from the
drop down list and attempt to continue past that field, error pops up "You
tried to assign the null value to a variable that is not a Variant data
type."


"Barry Gilbert" wrote in message
...
This tells us that the Me![ProductID].Text = "" statement is invalid. Try
removing the ".text" portion so that it reads:
Me![ProductId]=""

Barry

"jwr" wrote:


I put in the break, tried to run the routine, got message box to double
click, but it is not working. This takes me to the Code. The line that
says:

If IsNull(Me![ProductID]) Then
is highlighted with yellow (over the color that it changed to with
F9).

I press F8, then the line that reads:
Me![ProductID].Text = ""
is highlighted yellow.

I press F8 again, and
MsgBox Err.Description
is highlighted yellow.

Now I do not know what I should do next.

Thank you.


"Barry Gilbert" wrote in message
...
In your code, inside the ProductId_DblClick routine, put your cursor on
the
line that says:
If IsNull(Me![ProductID]) Then

and click F9. This will change the line's color, meaning it has a
break.
When (if) the code's execution reaches this line, it will stop. You can
then
click F8 to step through each line of code to try to see where it's
failing.

Barry


"jwr" wrote:

Sorry, I did not explain fully.

If my product is not in the drop down list, when I type the name, I
get a
pop-up form that says "Double Click on this to add." Double clicking
does
nothing. No errors, nothing.

I am not real knowledgeable in code. What do you mean, "If you put a
break
on your first line of code, does it stop execution there?"

Thanks

"Barry Gilbert" wrote in
message
...
When you say that it doesn't work, do you mean that the event isn't
firing
or
is there some other aspect of it that doesn't work. If you put a
break
on
your first line of code, does it stop execution there?

Barry

"jwr" wrote:

I have a subform that contains a combo box. ProductID is the
record
source.
Below is the code behind this field. I have another drop down list
with
double click that does work and I do not see anything different.

Your assistance is appreciated.


Private Sub ProductID_NotInList(NewData As String, Response As
Integer)
MsgBox "Double-click this field to add an entry to the list."
Response = acDataErrContinue
End Sub
Private Sub ProductID_AfterUpdate()
Me![UnitPrice] = Me![ProductID].Column(2)
End Sub
Private Sub ProductID_DblClick(Cancel As Integer)
On Error GoTo Err_ProductID_DblClick
Dim lngProductID As Long

If IsNull(Me![ProductID]) Then
Me![ProductID].Text = ""
Else
lngProductID = Me![ProductID]
Me![ProductID] = Null
End If
DoCmd.OpenForm "Products", , , , , acdialog, "GotoNew"
Me![ProductID].Requery
If lngProductID 0 Then Me![ProductID] = lngProductID

Exit_ProductID_DblClick:
Exit Sub

Err_ProductID_DblClick:
MsgBox Err.Description
Resume Exit_ProductID_DblClick
End Sub











  #8  
Old August 25th, 2006, 09:21 AM posted to microsoft.public.access.forms
Svetlana
external usenet poster
 
Posts: 80
Default Double-click to add not working

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

  #9  
Old August 25th, 2006, 05:34 PM posted to microsoft.public.access.forms
Access101
external usenet poster
 
Posts: 118
Default Double-click to add not working

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


  #10  
Old August 26th, 2006, 02:37 AM posted to microsoft.public.access.forms
jwr
external usenet poster
 
Posts: 21
Default Double-click to add not working

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 01:19 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.