Type mismatch issues. Creating Report based on checkbox selection

Beansy

Registered User.
Local time
Tomorrow, 05:39
Joined
Dec 19, 2012
Messages
20
Code:
Private Sub CreateReport_Click()
Dim Serv As String
Dim Manu As String
Dim Boil As String
Dim Steam As String
Dim Hot As String

    Serv = "[TypeOfWorkServicing] = '" & Me!Servicing & "'"
    Manu = "[TypeOfWorkManufacturing] = '" & Me!Manufacturing & "'"
    Boil = "[TypeOfWorkBoilers] = '" & Me!Boilers & "'"
    Steam = "[TypeOfWorkSteamSystems] = '" & Me!SteamSystem & "'"
    Hot = "[TypeOfWorkHotWater] = '" & Me!HotWater & "'"
    DoCmd.OpenReport "AllCustomers", acViewReport, , Serv And Manu And Boil And Steam And Hot

End Sub
Im trying to write code that creates a report based on the users selection of 5 checkboxes on a form by matching the check boxes selected to boxes checked in the table which contain the fields above. However I get an error on the Docmd.Openreport line complaining about type mismatch.
Can someone please help me with this?
 
Okay ive come up with easier to read code but still not working. Though this code executes and the Report is created but with no entries.

Code:
Private Sub CreateReport_Click()
Dim DocName As String



DocName = "AllCustomers"
 DoCmd.OpenReport DocName, acPreview, , "TypeOfWorkServicing= forms!WorkType!Servicing and TypeOfWorkManufacturing = forms!WorkType!Manufacturing and TypeOfWorkBoilers = forms!WorkType!Boilers and TypeOfWorkSteamSystems = forms!WorkType!SteamSystems and TypeOfWorkHotWater = forms!WorkType!HotWater "

End Sub
 
Try the query showed below:
DoCmd.OpenReport DocName, acPreview, , "TypeOfWorkServicing=" & "'" & Me.Servicing & "'" & " and TypeOfWorkManufacturing=" & "'" & Me.Manufacturing & "'" & " and TypeOfWorkBoilers=" & "'" & Me.Boilers & "'" & " and TypeOfWorkSteamSystems=" & "'" & Me.SteamSystems & "'" & " and TypeOfWorkHotWater =" & "'" & Me.!HotWater & "'"
 

Users who are viewing this thread

Back
Top Bottom