DoCmd.OpenReport

G

Guest

I need to open a report based on two conditions. One condition is a user's
name, which is provided from a listbox on a form. The other condition is a
start date(sd) and end date(ed), which are provided from two calendar
controls on a form. I am trying to use the code below to open the report but
it doesn't work. Do you know how I can open a report using the conditions
stated?

sd = Form_Calendar.beg_date
ed = Form_Calendar.end_date

strLinkCriteria = "[BG_Responsible]=" & "'" & Me.List54.Value & "'"
strReportCriteria = "[HS_CHANGE_DATE] between #" & sd & "# and #" & ed & "#"

DoCmd.OpenReport stDocName, acViewPreview, strReportCriteria, strLinkCriteria
 
K

Ken Snell \(MVP\)

Combine the two criteria into a single clause:

sd = Form_Calendar.beg_date
ed = Form_Calendar.end_date

strLinkCriteria = "[BG_Responsible]='" & Me.List54.Value & "' And " & _
"[HS_CHANGE_DATE] between #" & sd & "# and #" & ed & "#"

DoCmd.OpenReport stDocName, acViewPreview, , strLinkCriteria
 
G

Guest

Ken, thanks. Your tip worked great.

Ken Snell (MVP) said:
Combine the two criteria into a single clause:

sd = Form_Calendar.beg_date
ed = Form_Calendar.end_date

strLinkCriteria = "[BG_Responsible]='" & Me.List54.Value & "' And " & _
"[HS_CHANGE_DATE] between #" & sd & "# and #" & ed & "#"

DoCmd.OpenReport stDocName, acViewPreview, , strLinkCriteria

--

Ken Snell
<MS ACCESS MVP>



Lewis M said:
I need to open a report based on two conditions. One condition is a user's
name, which is provided from a listbox on a form. The other condition is a
start date(sd) and end date(ed), which are provided from two calendar
controls on a form. I am trying to use the code below to open the report
but
it doesn't work. Do you know how I can open a report using the conditions
stated?

sd = Form_Calendar.beg_date
ed = Form_Calendar.end_date

strLinkCriteria = "[BG_Responsible]=" & "'" & Me.List54.Value & "'"
strReportCriteria = "[HS_CHANGE_DATE] between #" & sd & "# and #" & ed &
"#"

DoCmd.OpenReport stDocName, acViewPreview, strReportCriteria,
strLinkCriteria
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top