Need code for iif has data

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

Guest

Hi all..

I have a text box with the field ActionTaken from the database displayed
in it. When the user picks one of the Actions it displays a report with the
picked action. What I would like is if there is no data for the report for
the ActionTaken text field to display "No Data". I have tried a couple codes
but I am getting now where. Any suggestions:

=IIF([HasData])????????? "No Data Available"

Rhett
 
Ofer..

Ok put it in... Now I am getting the error Run-Time error '2501':

The OpenReport Action was canceled"

Here is the code for the "View" button:

Private Sub cmdActionTaken_Click()
stDocName = "rptActionTaken"
DoCmd.OpenReport "rptActionTaken", acViewPreview, acEdit
End Sub

R~

Ofer Cohen said:
On the OnNoData Property of the report write the code

MsgBox "No Data"
Cancel = True

--
Good Luck
BS"D


Rhett_Y said:
Hi all..

I have a text box with the field ActionTaken from the database displayed
in it. When the user picks one of the Actions it displays a report with the
picked action. What I would like is if there is no data for the report for
the ActionTaken text field to display "No Data". I have tried a couple codes
but I am getting now where. Any suggestions:

=IIF([HasData])????????? "No Data Available"

Rhett
 
Try

Private Sub cmdActionTaken_Click()
stDocName = "rptActionTaken"
On Error Resume Next
DoCmd.OpenReport "rptActionTaken", acViewPreview, acEdit
End Sub


--
Good Luck
BS"D


Rhett_Y said:
Ofer..

Ok put it in... Now I am getting the error Run-Time error '2501':

The OpenReport Action was canceled"

Here is the code for the "View" button:

Private Sub cmdActionTaken_Click()
stDocName = "rptActionTaken"
DoCmd.OpenReport "rptActionTaken", acViewPreview, acEdit
End Sub

R~

Ofer Cohen said:
On the OnNoData Property of the report write the code

MsgBox "No Data"
Cancel = True

--
Good Luck
BS"D


Rhett_Y said:
Hi all..

I have a text box with the field ActionTaken from the database displayed
in it. When the user picks one of the Actions it displays a report with the
picked action. What I would like is if there is no data for the report for
the ActionTaken text field to display "No Data". I have tried a couple codes
but I am getting now where. Any suggestions:

=IIF([HasData])????????? "No Data Available"

Rhett
 
Ofer..

Thanks a bunch, works like a charm!!

R~

Ofer Cohen said:
Try

Private Sub cmdActionTaken_Click()
stDocName = "rptActionTaken"
On Error Resume Next
DoCmd.OpenReport "rptActionTaken", acViewPreview, acEdit
End Sub


--
Good Luck
BS"D


Rhett_Y said:
Ofer..

Ok put it in... Now I am getting the error Run-Time error '2501':

The OpenReport Action was canceled"

Here is the code for the "View" button:

Private Sub cmdActionTaken_Click()
stDocName = "rptActionTaken"
DoCmd.OpenReport "rptActionTaken", acViewPreview, acEdit
End Sub

R~

Ofer Cohen said:
On the OnNoData Property of the report write the code

MsgBox "No Data"
Cancel = True

--
Good Luck
BS"D


:

Hi all..

I have a text box with the field ActionTaken from the database displayed
in it. When the user picks one of the Actions it displays a report with the
picked action. What I would like is if there is no data for the report for
the ActionTaken text field to display "No Data". I have tried a couple codes
but I am getting now where. Any suggestions:

=IIF([HasData])????????? "No Data Available"

Rhett
 
Back
Top