Button press

fadetoblack

Registered User.
Local time
Today, 17:38
Joined
Aug 26, 2006
Messages
16
How do I make a botton on a form open a report when pressed?

thanks
 
Add your button to the form in design view.
A wizard will be started, just select the appropiate categories and actions.

Rv
 
Hi, I get no wizard. The button just draws on the form. I could go to properties to do it, but I don't know how to.
 
u can write code to open report in the button's click event. just write
"docmd.openreport" and spacebar, it will open a help of the function below ur code and u can write wht u want to do.
 
I've created a button through the wizard but when I click it, this comes up:


"compile error"

Option Compare Database

SELECT
FROM Query([Litters per year])
WHERE Month = [date?]

i've tried deleting it,but it just comes back
 
This is the way I do it though there may be a better way. Create the button by dropping it from the toolbox. In the button properties event tab click the builder beside on click (...) and choose macro builder. Name the macro and in ACTION navigate to and select open report (or query or whatever). In action arguments name the report and make the view print preview.

As I said, there may be a better way but this works. You'll have to do one for each button, possibly there is a way to have one macro do it, anyone?
 
i cant create or use any buttons as the error just comes up:

"compile error"

Option Compare Database

SELECT
FROM Query([Litters per year])
WHERE Month = [date?]
 
fadetoblack said:
i cant create or use any buttons as the error just comes up:

"compile error"

Option Compare Database

SELECT
FROM Query([Litters per year])
WHERE Month = [date?]
When you get the compile error select DEBUG I think. It should highlight the code that's faulty. Delete it and try again.
 
there is no debug to press. it comes up with "compile error - expected: case"
 
Open the form, that comes with the button that results in the error when clicked, in design mode.
Right click anywhere in the form and select Properties.
Now, select the button.
Navigate to the tab page called "Event"
In the On Click event, it will show [Event Procedure]
Click in the field, an icon with 3dots appears.
Click on thr icon, this will open the Microsoft Visual Basic editor.

Remove your erraneous code, that is, remove these lines

Code:
SELECT
FROM Query([Litters per year])
WHERE Month = [date?]

Now click on Save in the menu bar.

Next, try again adding a new button to your form as per the previous replies.
Also consider some reading / courses on VBA ;)

RV
 

Users who are viewing this thread

Back
Top Bottom