I'm using a list box to open a report for a specific record. I'm using a
report query for the report. The data in the list box updates the query. It
work fine except I would like to add some error handling before the report is
loaded. I would like to check to see if there is any data, if it is "null"
or no data provide a message box and exit before the report is loaded. I
cant seam to get pasted the if statement to check for the null. There must
be an easier way to get this accomplished. Any help would be appreciated.
Private Sub List14_AfterUpdate()
On Error GoTo Err_List14_Click
Dim stDocName As String
Dim stDocName2 As String
Dim stLinkCriteria As String
Dim stErrSiteNull As String
stDocName = "rptRebandingEquipFreq"
stDocName2 = "qryRebandingEquipFreq"
stErrSiteNull = "No Feeder System Set Yet, Try again Later!"
'open report Query and verify that there is data, if null close
query, message box and exit
DoCmd.OpenQuery stDocName2, acViewNormal
If IsNull(rs.Fields("SiteNum")) Then
DoCmd.Close
MsgBox stErrSiteNull, vbOKOnly, "Dude!"
GoTo Exit_List14_Click
Else
'If the query is not null close query and open report
DoCmd.Close
DoCmd.OpenReport stDocName, acViewPreview
End If
Exit_List14_Click:
Exit Sub
Err_List14_Click:
MsgBox Err.Description
Resume Exit_List14_Click
End Sub
|
|
0
|
|
|
|
Reply
|
Utf
|
4/26/2010 5:48:08 PM |
|
Check the number of records.
Better yet would be to use the report's no data event and trap the 2501 error
that gets generated if you cancel the report.
Report's Code
Private Sub Report_NoData(Cancel As Integer)
MsgBox "No Feeder System Set Yet, Try again Later!"
Cancel = True
End Sub
Your calling code
Private Sub List14_AfterUpdate()
On Error GoTo Err_List14_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "rptRebandingEquipFreq"
DoCmd.OpenReport stDocName, acViewPreview
End If
Exit_List14_Click:
Exit Sub
Err_List14_Click:
If Err.number <> 2501 THen
MsgBox Err.Description
End If
Resume Exit_List14_Click
End Sub
Otherwise you could try
IF DCount("*","qryRebandingEquipFreq") = 0 Then
Msgbox "No Feeder System Set Yet, Try again Later!"
Else
stDocName = "rptRebandingEquipFreq"
DoCmd.OpenReport stDocName, acViewPreview
End if
John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
Tim wrote:
> I'm using a list box to open a report for a specific record. I'm using a
> report query for the report. The data in the list box updates the query. It
> work fine except I would like to add some error handling before the report is
> loaded. I would like to check to see if there is any data, if it is "null"
> or no data provide a message box and exit before the report is loaded. I
> cant seam to get pasted the if statement to check for the null. There must
> be an easier way to get this accomplished. Any help would be appreciated.
>
> Private Sub List14_AfterUpdate()
> On Error GoTo Err_List14_Click
>
> Dim stDocName As String
> Dim stDocName2 As String
> Dim stLinkCriteria As String
> Dim stErrSiteNull As String
>
> stDocName = "rptRebandingEquipFreq"
> stDocName2 = "qryRebandingEquipFreq"
> stErrSiteNull = "No Feeder System Set Yet, Try again Later!"
> 'open report Query and verify that there is data, if null close
> query, message box and exit
> DoCmd.OpenQuery stDocName2, acViewNormal
> If IsNull(rs.Fields("SiteNum")) Then
> DoCmd.Close
> MsgBox stErrSiteNull, vbOKOnly, "Dude!"
> GoTo Exit_List14_Click
> Else
> 'If the query is not null close query and open report
> DoCmd.Close
> DoCmd.OpenReport stDocName, acViewPreview
> End If
>
> Exit_List14_Click:
> Exit Sub
>
> Err_List14_Click:
> MsgBox Err.Description
> Resume Exit_List14_Click
>
> End Sub
>
>
|
|
0
|
|
|
|
Reply
|
John
|
4/26/2010 7:48:50 PM
|
|
Thanks John. Works perfect, I used:
Private Sub List14_AfterUpdate()
On Error GoTo Err_List14_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim stErrSiteNull As String
stDocName = "rptRebandingEquipFreq"
stErrSiteNull = "No Feeder System Set Yet, Try again Later!"
'open report Query and verify that there is data, message box and exit
If DCount("*", "qryRebandingEquipFreq") = 0 Then
Beep
MsgBox stErrSiteNull, vbOKOnly, "Dude!"
Else
stDocName = "rptRebandingEquipFreq"
DoCmd.OpenReport stDocName, acViewPreview
End If
Exit_List14_Click:
Exit Sub
Err_List14_Click:
MsgBox Err.Description
Resume Exit_List14_Click
"John Spencer" wrote:
> Check the number of records.
>
> Better yet would be to use the report's no data event and trap the 2501 error
> that gets generated if you cancel the report.
>
> Report's Code
> Private Sub Report_NoData(Cancel As Integer)
> MsgBox "No Feeder System Set Yet, Try again Later!"
> Cancel = True
> End Sub
>
> Your calling code
> Private Sub List14_AfterUpdate()
> On Error GoTo Err_List14_Click
>
> Dim stDocName As String
> Dim stLinkCriteria As String
>
>
> stDocName = "rptRebandingEquipFreq"
> DoCmd.OpenReport stDocName, acViewPreview
> End If
>
> Exit_List14_Click:
> Exit Sub
>
> Err_List14_Click:
> If Err.number <> 2501 THen
> MsgBox Err.Description
> End If
> Resume Exit_List14_Click
>
> End Sub
>
>
> Otherwise you could try
> IF DCount("*","qryRebandingEquipFreq") = 0 Then
> Msgbox "No Feeder System Set Yet, Try again Later!"
> Else
> stDocName = "rptRebandingEquipFreq"
> DoCmd.OpenReport stDocName, acViewPreview
> End if
>
> John Spencer
> Access MVP 2002-2005, 2007-2010
> The Hilltop Institute
> University of Maryland Baltimore County
>
> Tim wrote:
> > I'm using a list box to open a report for a specific record. I'm using a
> > report query for the report. The data in the list box updates the query. It
> > work fine except I would like to add some error handling before the report is
> > loaded. I would like to check to see if there is any data, if it is "null"
> > or no data provide a message box and exit before the report is loaded. I
> > cant seam to get pasted the if statement to check for the null. There must
> > be an easier way to get this accomplished. Any help would be appreciated.
> >
> > Private Sub List14_AfterUpdate()
> > On Error GoTo Err_List14_Click
> >
> > Dim stDocName As String
> > Dim stDocName2 As String
> > Dim stLinkCriteria As String
> > Dim stErrSiteNull As String
> >
> > stDocName = "rptRebandingEquipFreq"
> > stDocName2 = "qryRebandingEquipFreq"
> > stErrSiteNull = "No Feeder System Set Yet, Try again Later!"
> > 'open report Query and verify that there is data, if null close
> > query, message box and exit
> > DoCmd.OpenQuery stDocName2, acViewNormal
> > If IsNull(rs.Fields("SiteNum")) Then
> > DoCmd.Close
> > MsgBox stErrSiteNull, vbOKOnly, "Dude!"
> > GoTo Exit_List14_Click
> > Else
> > 'If the query is not null close query and open report
> > DoCmd.Close
> > DoCmd.OpenReport stDocName, acViewPreview
> > End If
> >
> > Exit_List14_Click:
> > Exit Sub
> >
> > Err_List14_Click:
> > MsgBox Err.Description
> > Resume Exit_List14_Click
> >
> > End Sub
> >
> >
> .
>
|
|
0
|
|
|
|
Reply
|
Utf
|
4/26/2010 11:31:01 PM
|
|
|
2 Replies
203 Views
(page loaded in 0.135 seconds)
Similiar Articles: report - remove null fields - microsoft.public.access.reports ...Access 2007, I am making a report with several fields. If a field is null (contains no information), I want that field removed so that only fields c... Null Value in reports - microsoft.public.accessI have a report that has calculations. When a null value is in the calculation, the report displays a '#error' message. How do I get rid of the er... If Null - Display Text - microsoft.public.access.reports ...I have a report that tracks the dates certain events happen. i.e. Date Request received Date sent out Approval date etc... How do I get the report t... Counting Null Values in a Report - microsoft.public.access.reports ...I have a report that is grouped by people, then by Reason Closed. I want to count how many entries do not have a closed date. I tried the previous... Remove multiple rows of Null fields in a report - microsoft.public ...I have created a report with multiple lines of data that could be null. I set the fields to "can shrink." It does shrink the line and move it up a f... Null Is Null - microsoft.public.access.reportsThanks for the response, Allen! (and Al and Duane, too!) Since you and Duane touched on the "+" part of the string I thought I'd better explain. calculating with null values - microsoft.public.access.reports ...Blank may not mean Null if the field is a text field. Try this (note that you're missing the second argument for the IIf statement -- what value is to be used if the ... How to hide a text field label when the field is null? Access2003 ...The no-code method is to change the label to a text box and set its properties: Control Source: ="Mid. Name: " + [MiddleName] Can Grow: No Can Shrink ... Return null (blank) instead of zero - microsoft.public.access ...I have written an expression using the IIF function. It evaluates two number fields and performs a calculation. I would like to display null (blank... Null date parameter - microsoft.public.accessNull date parameter - microsoft.public.access Multivalue with Null value SSRS 2005 - microsoft.public.sqlserver ... Cached Report is returned when date parameter is NULL ... A Data Null Reporting MethodThis paper demonstrates a DATA NULL reporting method following the step-wise approach as specified below: 1. Design the report 2. Build a report matrix data set to ensure ... Report Builder and NULL valuesHi, I am trying to create a report with Report Builder, using a simple data model residing on SQL2005 reporting server. The problem that literally drives ... Empty-Paper on deviantARTArt - community of artists and those devoted to art. Digital art, skin art, themes, wallpaper art, traditional art, photography, poetry / prose. Art prints. SUGI 28: Next Generation Data NULL Report Writing Using ODS OO ...Paper 22-28 - 1 - Next Generation Data _NULL_ Report Writing Using ODS OO Features Daniel O’Connor, SAS Institute Inc., Cary NC ABSTRACT This paper is targeted for ... Empty and Null Data Points in Charts (Report Builder and SSRS)If you are displaying fields with empty or null values in your chart, the chart may not look as you expect. Charts process empty values differently depending on the ... 7/14/2012 10:32:57 PM
|