M
Masoud
I have used Dlookup function in the coding of before update of one control in
my form as below
but my coding does not work properly and gives the error "run-time error
2001", "you
canceled the previouse operation. and it willbe debug for Dlookup.
please help me.
Private Sub DefaultForDocument_BeforeUpdate(Cancel As Integer)
' Disallow update if there's not TRANSMITTAL yet
If IsNothing(Me.TRANSMITTAL) Then
MsgBox "You must select a TRANSMITTAL before you can set Default.", _
vbCritical, gstrAppTitle
Cancel = True
Exit Sub
End If
' Make sure there's only one default
' Check only if setting Default = True
If (Me.DefaultForDocument = True) Then
' Try to lookup another contact set Default
If Not IsNothing(DLookup("DocumentNo", "tblTransmittalls", _
"DocumentNo = " & Me.Parent.DocumentNo & _
" AND TRANSMITTAL <> " & Me.TRANSMITTAL & _
" AND DefaultForDocument = True")) Then
' ooops...
MsgBox "You have designated another TRANSMITTAL as the Default
for this Document." & _
" You must remove that designation before you can mark this
TRANSMITTAL as the Default.", _
vbCritical, gstrAppTitle
Cancel = True
End If
End If
End Sub
my form as below
but my coding does not work properly and gives the error "run-time error
2001", "you
canceled the previouse operation. and it willbe debug for Dlookup.
please help me.
Private Sub DefaultForDocument_BeforeUpdate(Cancel As Integer)
' Disallow update if there's not TRANSMITTAL yet
If IsNothing(Me.TRANSMITTAL) Then
MsgBox "You must select a TRANSMITTAL before you can set Default.", _
vbCritical, gstrAppTitle
Cancel = True
Exit Sub
End If
' Make sure there's only one default
' Check only if setting Default = True
If (Me.DefaultForDocument = True) Then
' Try to lookup another contact set Default
If Not IsNothing(DLookup("DocumentNo", "tblTransmittalls", _
"DocumentNo = " & Me.Parent.DocumentNo & _
" AND TRANSMITTAL <> " & Me.TRANSMITTAL & _
" AND DefaultForDocument = True")) Then
' ooops...
MsgBox "You have designated another TRANSMITTAL as the Default
for this Document." & _
" You must remove that designation before you can mark this
TRANSMITTAL as the Default.", _
vbCritical, gstrAppTitle
Cancel = True
End If
End If
End Sub