creating a button to run the report wizard (shortcut)

EnglisAP

Registered User.
Local time
Today, 14:05
Joined
Dec 16, 2010
Messages
20
I have the button working using the following coding. the issue i have is that either when i cancel the wizard or finish the wizard i get the same runtime error 2501. i would like to get rid of this error since the member accessing this button need to have no access to the actual coding and the only way out now is to debug the situation.

Code:
DoCmd.RunCommand (acCmdNewObjectReport)

Also would there be a way to delete the all reports on close of the whole program? just for future reference.
 
I have the button working using the following coding. the issue i have is that either when i cancel the wizard or finish the wizard i get the same runtime error 2501. i would like to get rid of this error since the member accessing this button need to have no access to the actual coding and the only way out now is to debug the situation.

Code:
DoCmd.RunCommand (acCmdNewObjectReport)

I would use Error handling code to trap error 2501.


Also would there be a way to delete the all reports on close of the whole program? just for future reference.

:confused: Surely you don't really mean from the actual (Access) program.

I think you are acting how to delete all the report objects from the current database ?
 
You are giving users the power to create reports via the built-in wizard?? This is risky business because they can get to your code.
 
the only users the will use this form are the CEO and the it director of the company. but the issue is that there will not be a generic report this reports will alter each time we will create one so for easy of the program i have made the shortcut button.
 
the other question i have is how do i go about trapping this error so that it just ignores it instead of having to debug and close the window
 
I would urge you to use error handling in all your Access projects.

It would be something like this:

Code:
Public Function RunReportWizard()

On Error GoTo PROC_ERR

DoCmd.RunCommand (acCmdNewObjectReport) 

PROC_EXIT:
    Exit Function

PROC_ERR:
    
   If Err.Number <> 2501 Then 
       MsgBox "Error: (" & Err.Number & ") " & Err.Description, vbCritical
   End if
   Resume PROC_EXIT
End Function
 
im sorry im fairly new to this coding would i put that in the onclick command like i have the code now? or is this placed as additional code to the program.
 
Yes you could use it on the On Click events Subroutines (Sub).

I normally use Error Handling code in ever Subroutine and function. This includes the events of objects and User Defined Subroutines and Functions in modules.

I urge you to read the information in the two links I provided.
 
i plan on reading the information you posted but for the sake of ease and time is there a way you could post the code for that which i will use for the on-click command. i tried it as is but it does not work... i start classes on Monday and will have time to read through the links unfortunately i have to have this database done by close of business today.
 
i plan on reading the information you posted but for the sake of ease and time is there a way you could post the code for that which i will use for the on-click command. i tried it as is but it does not work... i start classes on Monday and will have time to read through the links unfortunately i have to have this database done by close of business today.

You could also use the code I posted placed in a module. The reason I posted it as function is that with a function you can call it from a command button on a form, and/or a button on a toolbar, and/or a macro.

The code I posted would be the same for a On Click event with only one line needing to be changed. The Exit Function needs to be updated to Exit Sub.
 
thank you for all your help the database is now complete and on time. i promise for all your efforts i will start to use error trapping and i will read those posts as soon as i have time. once again thank you for all your help 4 stars to you.
 
You're welcome.

Glad we could assist.

Note: An this forum, please feel free to click on the scale icon to the right of the Post # in the upper right corner of one of my posts to show your appreciation.
 

Users who are viewing this thread

Back
Top Bottom