View Single Post
  #5  
Old October 2nd, 2006, 10:19 PM posted to microsoft.public.access.forms
DawnTreader
external usenet poster
 
Posts: 198
Default Double Click to add

"JNana" wrote:

My apologies for not providing enough information. Following is the SQL for
my subform.

SELECT DISTINCTROW [Order Details].OrderDetailID, [Order Details].OrderID,
[Order Details].LineItem, [Order Details].ProductID, [Order
Details].SerialNum, [Order Details].Quantity, [Order Details].UnitPrice,
[Order Details].Discount, Round([Quantity]*[Order
Details].UnitPrice*(1-[Discount]),2) AS [Line Total], [Order
Details].ProductCode, [HandlingPct]*Round([Quantity]*[Order
Details].UnitPrice*(1-[Discount]),2) AS HandlingChg, [Order Details].Notes
FROM Products INNER JOIN [Order Details] ON Products.ProductID = [Order
Details].ProductID
ORDER BY [Order Details].LineItem;



Following is the information behind the double-click event for my combo box.

Private Sub cboProduct_DblClick(Cancel As Integer)
If Me.OpenArgs = "GotoNew" And Not IsNull(Me![ProductID]) Then
DoCmd.DoMenuItem acFormBar, 3, 0, , acMenuVer70
End If
End Sub



This is the field (from the main form) that does work on double-click. I
copied this and inserted the VBA in the event procedure for my combo box. I
inserted cboProduct in place of ShippingMethodID, but it did not work for
me.

Private Sub ShippingMethodID_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 ShippingMethodID_DblClick(Cancel As Integer)
On Error GoTo Err_ShippingMethodID_DblClick
Dim lngShippingMethodID As Long

If IsNull(Me![ShippingMethodID]) Then
Me![ShippingMethodID].Text = ""
Else
lngShippingMethodID = Me![ShippingMethodID]
Me![ShippingMethodID] = Null
End If
DoCmd.OpenForm "Shipping Methods", , , , , acdialog, "GotoNew"
Me![ShippingMethodID].Requery
If lngShippingMethodID 0 Then Me![ShippingMethodID] =
lngShippingMethodID

Exit_ShippingMethodID_DblClick:
Exit Sub

Err_ShippingMethodID_DblClick:
MsgBox Err.Description
Resume Exit_ShippingMethodID_DblClick
End Sub


you also need to change the "shipping methods" form to what form you are
using to add the new data to the table. ie: "cboProductEntryForm"