isempty does not work on new records

G

Guest

If the field DocId as any data I want the user to be able to print a report.
If the field DocId the user will not have the option to print.
I have built the above code.
The problem is that it acts as if DocId was never empty. Not even in a new
record, with any data.

Private Sub Form_Close()
Dim strMsg As String

If Not IsEmpty(Me.DocID) Then
strMsg = "Deseja imprimir o documento?"
If MsgBox(strMsg, vbQuestion + vbYesNo, "Impressão") = vbYes Then
DoCmd.OpenReport "Factura", acViewNormal, "", "", acNormal
End If
End If
End Sub

I can’t understand why. Can anyone help me?
 
D

Douglas J. Steele

IsEmpty is only intended to work with variables.

You appear to be trying to use it with either a control on a form, or a
field in that form's Recordsource.

Assuming that you have no default value set for the control or field, try
using the IsNull function instead.
 
G

Guest

Thank you for your reply,
I tried with isnull, the same result.

Private Sub Form_Close()
Dim strMsg As String

If Not Isnull(Me.DocID) Then
strMsg = "Deseja imprimir o documento?"
If MsgBox(strMsg, vbQuestion + vbYesNo, "Impressão") = vbYes Then
DoCmd.OpenReport "Factura", acViewNormal, "", "", acNormal
End If
End If
End Sub


"Douglas J. Steele" escreveu:
 

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

Top