Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error only under Access Runtimes - works in develop edition 1

Status
Not open for further replies.

mdweezer

Technical User
Jun 15, 2004
56
US
I have a form with a bunch of checkboxes, to procede to the next form you need at least 1 of them to be checked. So I run a if statement on each checkbox and end up with:
Code:
If AreBlank = True Then
MsgBox "You must select at least 1 Product", vbOKOnly, "Error"
End
End If

This works fine for me, however when we sent the DB to the person who will actually be using it who is only running the access runtimes says after they get that error box, the application totally shuts down on them. Is using "end" the correct way to go?
 
I would delete the END line from your code and go straight to End If. I have never seen it used before.

If you want to exit from the form sub / function / whereever this code is stored, then write

Exit Sub

Stylistically, I would consider having the same test that looks to see if any of the check boxes have been completed move the cursor back to the first check box whenever it is determined that no checkboxes have been checked, immediately after the msgbox message is displayed. This can be done by calling the control by name.

[Forms]![frmFormWithCheckboxes]![cbxFirstCheckbox].setfocus

Hope this helps.
 
Hi,
I think this must be your code to check the false or null state of the checkboxes
Code:
'Check if the checkboxes are False(White color but not selected)
If (Me.Check2 = False) Or (Me.Check4 = False) Or (Me.Check6 = False) Then
MsgBox "Not selected"
Else
'Check if the checkboxes are in the grey style(Null Value)
If IsNull(Me.Check2) Then
If IsNull(Me.Check4) Then
If IsNull(Me.Check6) Then
MsgBox "Not selected"
End If
End If
End If
End If
regards

Zameer Abdulla
 
Replacing "End" with "Exit Sub" worked great. But now on another set of code on a report:
Code:
Private Sub Report_NoData(Cancel As Integer)
MsgBox "Currently no status exist under that Milestone", vbOKOnly
End
End Sub

Again, this code works fine for me, a form is run, data is selected, if data is there it prints out the repoty, if not it runs the code above and returns to the form fine, but the person running off the access runtime says it shuts down on him. I tried using the "Exit Sub" but it shows the empty report afterwards. That is what i'm trying to avoid on this one, showing a empty report, if there is no data I don't want the report to be shown empty and for the user to be brought back to the form they were just on, which the above code works for me, but not for the gentlemen working with the access runimes.
 
Run your test for completion before calling DoCmd.OpenReport "rptReportName".

Also introducing error handling into your code will allow the runtime version of Access to exit from an error without crashing. You can get fancier with the error handling by placing the form name that holds the code module and the event that triggered the error into the output of the message box ax either message box text or within the title bar of the message box.

You will have to write your own test as I do not know enough about your database to write a test for you. What you may want to do is write a query that will count the number of records in your report, then have a pop-up form appear that will display this record count. You could then use VBA to read the value stored within the text box control on the pop-up form and see if that value is greater than zero. Once this test is performed you can use the docmd.close acform "frmPopUpFormName" language to close the form. To the end user this will usually result in a flash on their monitor. Even Lotus Notes 4.6 uses this method to test values before launching the client software for their product.

=========================================================
Private Sub Report_NoData(Cancel As Integer)
on error goto Err_Report_NoData

if {test is true} then

DoCmd.OpenReport "rptReportName"

Else

MsgBox "Currently no status exist under that Milestone", vbOKOnly

end if

Exit_Report_NoData:
Exit Sub

Err_Report_NoData:
msgbox err.description
resume Exit_Report_NoData

End Sub
=========================================================
 
Have you tried this ?
Private Sub Report_NoData(Cancel As Integer)
MsgBox "Currently no status exist under that Milestone", vbOKOnly
Cancel = True
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top