Report criteria

MarionD

Registered User.
Local time
Today, 11:48
Joined
Oct 10, 2000
Messages
425
Hi there... here's hoping someone can help me!
I have a form where I "collect" the criteria to print a report. The fields are as per the attachment, HHA (text), Date from - till, And a list field where one or more items can be marked.

Now I need to print a report: I have tried the following code but it's not working.
Dim Docname As String
Dim sqlstart As Variant, sqlend As Variant
Dim strwhere As String
Dim varitem As Variant
Dim HHA As String
Dim Linkkrit As String
sqlstart = "#" & Format(Me.anfang, "mm-dd-yyyy") & "#"
sqlend = "#" & Format(Me.ende, "mm-dd-yyyy") & "#"
HHA = "'" & Me.HHA & "'"
strwhere = ""
For Each varitem In Me.Gemeinde.ItemsSelected
strwhere = strwhere & "tblxx_Gemeinde_ID =" & Me.Gemeinde.Column(0, varitem) & " Or "
Next varitem
If strwhere > "" Then strwhere = Left(strwhere, Len(strwhere) - 4)

If strwhere = "" Then
MsgBox "Sie müssen eine oder mehrere Gemeinde auswählen", vbExclamation, ThisProgName
Exit Sub
End If

Docname = "rpt_Taetigkeiten"
Linkkrit = (strwhere) And "[HHA]=" & HHA And "[Arbdatum] >=" & sqlstart And "[Arbdatum] <=" & sqlend
DoCmd.OpenReport Docname, A_PREVIEW, , Linkkrit

I would really appreciate it if someone can point me in the right direction!
Marion
 

Attachments

  • Form.JPG
    Form.JPG
    32.9 KB · Views: 152
You're not restarting the string after a variable

"...HHA = " & HHA & " And...
 
Thanks a million

Marion
 

Users who are viewing this thread

Back
Top Bottom