Disable Double Click

B

Bob V

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
 
B

Bob V

Added this to my code now it seems to work is this what they mean by
catching an error???...Bob
On Error Resume Next

If Err.Number = 3075 Then
MsgBox "This application has detected newer versions " _
& "of required files on your computer. " _
& "It may take several minutes to recompile " _
& "this application."
Err.Clear
End If
 
T

Tom Wickerath

T

Tom Wickerath

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/expert_contributors.html
__________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top