Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

vba

ResolvedVersion 2003

Joanne has attended:
Access VBA course

Vba

Hi I a code to print out a report sheet but I needed the code to check that the results are correct first and if not then tell the user to select a different check box. Well the code does that as far as tell the user to select the correct box but when you select the correct box the code does not do enthing? Can some one help please.
'------------------------------------------------------------
' PRINT_REPORT
'
'------------------------------------------------------------
Function PRINT_REPORT()
On Error GoTo PRINT_REPORT_Err

With CodeContextObject
If (.CheckChoice = 1 And .RingAppr = "Not Approved") Then
Beep
MsgBox "1st Off Not Approved please select SETTING tick box", vbExclamation, "NOT APPROVED"
End If
Exit Function
DoCmd.Close acForm, "ENTER DATA"
DoCmd.OpenReport "Inner Ring Result page", acViewPreview, "", "", acNormal
DoCmd.PrintOut acPages, 1, 1, acHigh, 1, True
DoCmd.Close acReport, "Inner Ring Result page"
DoCmd.OpenForm "Switchboard", acNormal, "", "", , acNormal
End With


PRINT_REPORT_Exit:
Exit Function

PRINT_REPORT_Err:
MsgBox Error$
Resume PRINT_REPORT_Exit

End Function

RE: vba

Hi Joanne

A first glance shows that your exit function command is outside of the block IF. Therefore it runs regardless of the selection.
Place it inside the block iif and see if this solves the problem

Any further problems please get back to me

Regards

Stephen

Tue 12 Jan 2010: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Access tip:

Remove spaces in a table

If you have a table that has too many space marks littered around, you can create a update query and use the trim function to get rid of any excess space marks

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.