Canceling a double-click event

  • Thread starter Christine Vollberg via AccessMonster.com
  • Start date
C

Christine Vollberg via AccessMonster.com

Ok this is probably a very dumb question but it is making me a little nuts.
I have a subform that if you double click in a field it opens up a
information form based on the data in the field. But I want to cancel the
open form if the field is blank. Can't seam to get anything to work. It
opens the form either way. Here is the double-click event.

Private Sub JudgeBarRollNo_DblClick(Cancel As Integer)

Dim stDocName As String
Dim stLinkCriteria As String

If Me![JudgeBarRollNo] = Null Then
MsgBox "No Record has been selected"
Cancel = True
Exit Sub
Else

stDocName = "frmEnterAttorney/JudgeInformation"
stLinkCriteria = "[BarRollNo]=" & "'" & Me![JudgeBarRollNo] & "'"
DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria
End If
End Sub

Anyhelp would be greatly appreciated.
 
J

John Webb via AccessMonster.com

Nulls are funny things, try this:

***CODE BEGINS***

Private Sub JudgeBarRollNo_DblClick(Cancel As Integer)

Dim stDocName As String
Dim stLinkCriteria As String

If IsNull(Me.JudgeBarRollNo) Then
MsgBox "No Record has been selected"
Cancel = True
Else
stDocName = "frmEnterAttorney/JudgeInformation"
stLinkCriteria = "[BarRollNo]=" & "'" & Me.JudgeBarRollNo & "'"
DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria
End If
End Sub

***CODE ENDS***

Think that should work.

Cheers

John Webb
 
G

Guest

Double Click BAD - Single Click GOOD

Do you have anything in your Click Event (Single I mean)?
Often times the Click Event and the Double Click Event both fire.

Better Code:

If IsNull(Me![JudgeBarRollNo]) or Me![JudgeBarRollNo]= ""l Then
 
J

John Webb via AccessMonster.com

even better code (if you wanted to be picky):

If Nz(Me.JudgeBarRollNo,"") = "" Then
 

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