Hi Bob,
Try this modification:
Private Sub tbAdditionCharge_DblClick(Cancel As Integer)
If Me.OpenArgs = "HoldingInvoice" Then
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAdditionalCharges"
stLinkCriteria = "[ChargeNumber]=" & Me![tbChargeNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Sub
Here is an alternate form, that eliminates the stDocName and stLinkCriteria
variables (these are really not needed), uses named arguments with the :=
(colon equal), eliminating the need for positional arguments, and adds error
handling, since pretty much all procedures should include error handling:
Private Sub tbAdditionCharge_DblClick(Cancel As Integer)
On Error GoTo ProcError
If Me.OpenArgs = "HoldingInvoice" Then
DoCmd.openForm FormName:="frmAdditionalCharges", _
WhereCondition:="[ChargeNumber]=" & Me![tbChargeNumber]
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure tbAdditionCharge_DblClick..."
Resume ExitProc
End Sub
You can also use a SELECT Case....END SELECT construct, as in this example:
Private Sub tbAdditionCharge_DblClick(Cancel As Integer)
On Error GoTo ProcError
Select Case Me.OpenArgs
Case "HoldingInvoice"
DoCmd.openForm FormName:="frmAdditionalCharges", _
WhereCondition:="[ChargeNumber]=" & Me![tbChargeNumber]
Case "ModifyOldInvoice"
MsgBox "This action is not available with old invoices.", _
vbInformation, "Disabled DoubleClick"
Case Else
'Enter some default action if the form can be opened
'without an openarg argument
End Select
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure tbAdditionCharge_DblClick..."
Resume ExitProc
End Sub
Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/ex...tributors.html
__________________________________________
"Bob V" wrote:
>
> My form opens in 2 different arguments
> If Me.OpenArgs = "ModifyOldInvoice" Then
> If Me.OpenArgs = "HoldingInvoice" Then
>
> Can I disable the double click in "ModifyOldInvoice"
> because it works on "HoldingInvoice" Only and is giving me a Error on
> "ModifyOldInvoice"
>
> My Double click Code:
> Private Sub tbAdditionCharge_DblClick(Cancel As Integer)
> Dim stDocName As String
> Dim stLinkCriteria As String
> stDocName = "frmAdditionalCharges"
>
> stLinkCriteria = "[ChargeNumber]=" & Me![tbChargeNumber]
> DoCmd.OpenForm stDocName, , , stLinkCriteria
> End Sub
> Thanks for any help..Bob