IsEmpty - macro problems...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a database, which you can make ONE label and then you can print the
label in 19 languages BUT if the field "Productname" is empty, it should
stop... but I can't seen to get it working right..

F.x.: Productname in UK are "Product 1" and Productname in Austria is empty
(no sale)

---
Private Sub Button_Print_Austria_Click()
On Error GoTo Err_Button_Print_Austria_Click

Dim stDocName As String
Dim MyCheck, Response, Msg, Style, Title

Msg = "This product is not available in Austria! Do you wish to
continue?"
Style = vbYesNo + vbCritical
Title = "Warning!"

MyCheck = IsEmpty(Productname)

MsgBox (Productname)

If MyCheck = True Then

Response = MsgBox(Msg, Style, Title)

If Response = 6 Then (Have tried vbYes but it didn't work)

stDocName = "Master_A"
DoCmd.OpenReport stDocName, acNormal, , "[M-ID]=" & [M-ID]
MyCheck = False

End If

End If

If MyCheck = False Then

stDocName = "Master_A"
DoCmd.OpenReport stDocName, acNormal, , "[M-ID]=" & [M-ID]

End If

---
 
Torben,

Your question relates to a VBA procedure, not a macro.

You should declare the type for your variables.

The IsEmpty function is not applicable to a field or control. Should be
IsNull.

Try like this...

Dim stDocName As String
Dim MyCheck As Boolean
Dim Response As Integer
Dim Msg As String
Dim Style As String
Dim Title As String

Msg = "This product is not available in Austria! Do you wish to
continue?"
Style = vbYesNo + vbCritical
Title = "Warning!"
stDocName = "Master_A"
MyCheck = IsNull(Me.Productname)
MsgBox (Me.Productname)

If MyCheck Then
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
DoCmd.OpenReport stDocName, , , "[M-ID]=" & Me![M-ID]
MyCheck = False
End If
Else
DoCmd.OpenReport stDocName, , , "[M-ID]=" & Me![M-ID]
End If
 
Sorry... it IS a VBA question but I'm new here... :o)

It didn't work or as I have put into the Report and not the Form, so...
but you did give me some idea... IsNull.

I will keep working... Thanks!

"Steve Schapel" skrev:
Torben,

Your question relates to a VBA procedure, not a macro.

You should declare the type for your variables.

The IsEmpty function is not applicable to a field or control. Should be
IsNull.

Try like this...

Dim stDocName As String
Dim MyCheck As Boolean
Dim Response As Integer
Dim Msg As String
Dim Style As String
Dim Title As String

Msg = "This product is not available in Austria! Do you wish to
continue?"
Style = vbYesNo + vbCritical
Title = "Warning!"
stDocName = "Master_A"
MyCheck = IsNull(Me.Productname)
MsgBox (Me.Productname)

If MyCheck Then
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
DoCmd.OpenReport stDocName, , , "[M-ID]=" & Me![M-ID]
MyCheck = False
End If
Else
DoCmd.OpenReport stDocName, , , "[M-ID]=" & Me![M-ID]
End If

--
Steve Schapel, Microsoft Access MVP


Torben said:
I have a database, which you can make ONE label and then you can print the
label in 19 languages BUT if the field "Productname" is empty, it should
stop... but I can't seen to get it working right..

F.x.: Productname in UK are "Product 1" and Productname in Austria is empty
(no sale)

---
Private Sub Button_Print_Austria_Click()
On Error GoTo Err_Button_Print_Austria_Click

Dim stDocName As String
Dim MyCheck, Response, Msg, Style, Title

Msg = "This product is not available in Austria! Do you wish to
continue?"
Style = vbYesNo + vbCritical
Title = "Warning!"

MyCheck = IsEmpty(Productname)

MsgBox (Productname)

If MyCheck = True Then

Response = MsgBox(Msg, Style, Title)

If Response = 6 Then (Have tried vbYes but it didn't work)

stDocName = "Master_A"
DoCmd.OpenReport stDocName, acNormal, , "[M-ID]=" & [M-ID]
MyCheck = False

End If

End If

If MyCheck = False Then

stDocName = "Master_A"
DoCmd.OpenReport stDocName, acNormal, , "[M-ID]=" & [M-ID]

End If
 
Back
Top