report by combo box and logo

Hi i think you have cracked it, it works with all demolition ones now and also if it si another criteria then just is blank...... many thanks for your brilliant help...

Can I be really cheeky now or if you prefer me to open another posting I can.

My intention is now to have 3 reports one for demolition (now working) and one for Combination and one for Management.

Therefore, if the record is Combination and it needs to print the combination report then how can I code this. I assume ti is a type of IF statement.

Thanks again your help as been very good.
 
An if statement is one option, though it leaves rather untidy code.

I would prefer to add a ReportName field to TableSurveyTypes & include it at the end of the query which the combobox is based on.

That way all the code you need is:

Code:
DoCmd.OpenReport [B]Combo38.Column(2)[/B], acPreview, , "type = '" & Combo38[B].Column(1)[/B] & "' AND IDquote = " & idquote

This way the VBA will pull both the type and the report name from the combobox with a single line of code.

:edit:

the table would look something like:

ID | Type | qrptid | ReportName
1 | Combustion | QC | rptCombinationReport
...
...
 
In this instance I will add a column into the surveytypes table as you suggest

beofre I adjust the coding do I still need the stDocName in the code line or does the new combo command take over this, i will try it anyhow

Thanks
 
You are no longer using stDocName for anything so it can be deleted.
 
Hi

Ok I have added in the surveytypes a file that has the name of the report next to the relevant type. I ahve changed the code to the below and now I am getting this error message saying " The action or method requires a report name arguement"

I ahve taken out the stdocname and also tried taking out the line stDocName = "quotedem" but no luck..... any ideas, we are so close

Private Sub Command98_Click()
On Error GoTo Err_Command98_Click
Dim stDocName As String
stDocName = "quotedem"
DoCmd.OpenReport Combo38.Column(4), acPreview, , "type = '" & Combo38.Column(1) & "' AND IDquote = " & idquote

Exit_Command98_Click:
Exit Sub
Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click

End Sub
 
Column(4)?

The column count starts at 0 for the first column, so you are trying to use the 5th field in the query as the report name.

Is this what you meant, or did you mean the 4th field (which is column(3))?

Also, if you have edited the combobox query make sure the type name (i.e. "demolition", etc) is still the second field in the query still, otherwise you will need to update the column(1) in the VBA too.
 
Hi

Ok I tried them all and it ended up being 2????? How do you know which field is which???

Anyhow the really good news is it now works.. Cant thank you enough many many thanks for this..... and of course it as been a good learning curve for myself....

Thank you
 
As the count starts at 0 instead of 1 the column number will always be 1 lower than the field number.

So column(2) is field 3 (it's also the column I told you to use when I posted the code in post #22! :p).
 

Users who are viewing this thread

Back
Top Bottom