Reopen switchboard on report having no data

BarryMK

4 strings are enough
Local time
Today, 04:48
Joined
Oct 15, 2002
Messages
1,349
I'm using the following code to fire a message box on no data for a report but can't get it to reopen the switchboard which is minimized after calling the report. I've tried placing the DoCmd in the three places shown in red but none of them work.


Private Sub Report_NoData(Cancel As Integer)
On Error GoTo Err_Report_NoData

MsgBox "There are no current QA incidents. Cancelling Preview...", vbInformation, " No records found"
Cancel = True
DoCmd.OpenForm "Switchboard"


Exit_Report_NoData:
DoCmd.OpenForm "Switchboard"
Exit Sub

Err_Report_NoData:
MsgBox err.Description, , "Database service "
Resume Exit_Report_NoData
DoCmd.OpenForm "Switchboard"
End Sub
 
almost there - this kinda thing bugged me for ages

1) On no data in the report set focus to the form:

usually Forms!...SetFocus etc

Then
Code:
 DoCmd.Restore

no guarantee - if it doesn't work - reply and i'll see what i can do
 
Thanks I'll try it and let you know what happens.
 
Hi Rich

Hope the sun's shining nicely down there as always, my stepdaughter and bloke are coming down to Golant by Fowey tonight for a few days at the Cormorant while I stay an finish the new kitchen... :(



Private Sub cmdDueQA_Click()
On Error GoTo Err_cmdDueQA_Click

DoCmd.SetWarnings False
DoCmd.Minimize
DoCmd.OpenQuery "Calc01", acNormal, acEdit
DoCmd.OpenReport "Due for action QA", acPreview, "", ""

Exit_cmdDueQA_Click:
Exit Sub

Err_cmdDueQA_Click:
If err.Number = 2501 Then
Else
'message and cancel if no data
MsgBox err.Number & "-" & err.Description
End If
Resume Exit_cmdDueQA_Click
End Sub
 
Why are you opening a query?
The weather's only reasonable at the minute, it's not looking good for the weekend :(
Easter's too early this year, what clown keeps moving it :mad:
 
Rich said:
Why are you opening a query?
The weather's only reasonable at the minute, it's not looking good for the weekend :(
Easter's too early this year, what clown keeps moving it :mad:

The query runs an elapsed time calculation for the report.

If the weather's good up here for one day I'm staying in the garden - Stratford will be full of tourists. Easter hols should be moved to the end of May we might get a weekend worth having off.
 
If the Report's based on the query then there's no need to open the query first
 
I'm having a hard time figuring out what the query's purpose is, let's try it without first and see what happens

DoCmd.OpenReport "Due for action QA", acPreview, "", ""
MySwitchboard.Visible = False


try it with no data and see if the Cancel=True part works :)
 

Users who are viewing this thread

Back
Top Bottom