Report One Line Of Data

Remember you could also look in the help files (hit F1 in the vba editor) for a more precise explanation on the Docmd.OpenReport method.

Do you have the code in the CLICK event of the button? The code block should look something like this (assuming Command1 is the name of the button):

Code:
Private Sub Command1_Click()
[B]     DoCmd.OpenReport "rpt_risktype", , , "Risk_ID = " & Val(Me.Risk_ID)[/B]
End Sub

I've modified your code a bit so you use the above line in bold.
 
I'm trying to make this work through a list box in a form, with the code in the 'on click' section:

Private Sub Combo3_Click()
DoCmd.OpenReport "rpt_risktype", , , "Risk_ID = " & Me.Risk_ID
End Sub
Mentioning that you're using a combo box (not a list box) is crucial too. The code syntax doesn't suit a combo box. It's fine to have the Risk_ID and Risk_Type in a combo box but don't put the code in there. Create a button and put the following code in the CLICK event:

DoCmd.OpenReport "rpt_risktype", , , "Risk_ID = " & Val(Me.Combo3.value)

I'm right to think that the combo box holds the Risk_IDs and Risk_Types?
 
The code is in the CLICK event yes.

I get a 'compile error' now with the Risk_ID inside the brackets highlighted.
 
Right, but is it now in the CLICK of a BUTTON? Not the Combo box.

What's the exact error message?
 
'Method or data member not found'

That's from the 'click' event in a button
 
Something changed now, I have a print on the way. Ha ha!!! That's cracked it :)

The list box and then button click has got it sorted, wow.

I'm sure I can get it to display rather than print now, that's genius.
 
Gee, what to say? That's patience and perseverance in spades; thank you :)
 
Glad you got there in the end. Now you can do it with your eyes closed :)

You're welcome.
 

Users who are viewing this thread

Back
Top Bottom