Quary in a form to report-Problem

  • Thread starter Thread starter alrun
  • Start date Start date
A

alrun

Guest
Hi there
I have maked a quary from on master tabel, and a form out of this qyary.

The problem is that I want to make a user friendly quary builder, from combo boxes... 8 and a on textbox. I should be posseble to use all of them or just one...the results would be insertet into a report.
If thar is any one who can, this might help.

Qyary name: "Projekt Forespørgsel" and it has only one table "Projekt".

The form that I have created has following comboboxes (and textbox):

(Textb) "År"
(cbo) "Sagsleder"
"Sektion"
"Bygherre"
"Reference"
"SAPArkitekt"
"EntrepriseForm"
"SAPLandskabsarkitekt"
"SAPIngenior"

I use also a submit button to "Print Preview"


Private Sub cmdPrintPreview_Click()

Dim strReportName As String
Dim strCriteria As String

If NewRecord Then
MsgBox "This record contains no data. Please select a record to print or Save this record." _
, vbInformation, "Invalid Action"
Exit Sub
Else
strReportName = "rptProjekt_rapport"
strCriteria = "[Sektion]= " & Me![Sektion]


DoCmd.OpenReport strReportName, acViewPreview, , strCriteria



End If






End Sub



How will this work?

Sincerely
Alrun
 
You would need to make the query read values from each combo/text box if they contain data:
Code:
SELECT [Projekt].*
FROM [Projekt]
WHERE (((IIf([Forms]![SearchForm]![Sektion] Is Null,([Projekt].[Sektion]) Is Not Null,([Projekt].[Sektion]))) Like "*" & [Forms]![SearchForm]![Sektion] & "*"));
 

Users who are viewing this thread

Back
Top Bottom