Opening reports based on cetain values

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a button on a form to open a report based on a
value of a field on the form ([field2]) which works fine
(Code Below). I want to also used a second criteria eg
where all field3 are = null. I it possible to do this
using this method and how do I do it.


Thanks in advance


Martin


stDocName = "rptOne"
stLinkCriteria = "[field1]=" & "'" & Me![field2] & "'"
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
 
try this:
stLinkCriteria = "[field1]=" & "'" & Me![field2] & "' and
isnull([field3])"
good luck

I have a button on a form to open a report based on a
value of a field on the form ([field2]) which works fine
(Code Below). I want to also used a second criteria eg
where all field3 are = null. I it possible to do this
using this method and how do I do it.


Thanks in advance


Martin


stDocName = "rptOne"
stLinkCriteria = "[field1]=" & "'" & Me![field2] & "'"
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
 
I use the following code:

dim strWhere as string

if isnull(WhatCity) = false then
strWhere = "City = '" & WhatCity & "'"
endif

' Get combo box for sales man (blank = all)

if isnull(cboWhatSalesRep) = false then

if strWhere <> "" then
strWhere = strWhere & " and "
endif

strWhere = strWhere & "SalesRep = '" & cboWhatSalesRep & "'"
endif

' you can continue the above for as many conditions you have.
' then launch the report

DoCmd.OpenReport "yourReprot", acViewPreview, , strWhere

Here is some screen shots of where I do exactly the above. Note how OFTEN I
have instructions on the forms for "blank = all". The code I use is
identical as above. Check out:

http://www.attcanada.net/~kallal.msn/ridesrpt/ridesrpt.html

Just remember, string values need to be surrounded by quotes, and number
values, or combo box id values do NOT need the quotes. And, dates need #.
 
Thanks. That works OK
-----Original Message-----
try this:
stLinkCriteria = "[field1]=" & "'" & Me![field2] & "'
and
isnull([field3])"
good luck

<[email protected]> escribió en el mensaje
I have a button on a form to open a report based on a
value of a field on the form ([field2]) which works fine
(Code Below). I want to also used a second criteria eg
where all field3 are = null. I it possible to do this
using this method and how do I do it.


Thanks in advance


Martin


stDocName = "rptOne"
stLinkCriteria = "[field1]=" & "'" & Me![field2] & "'"
DoCmd.OpenReport stDocName, acViewPreview, ,
stLinkCriteria


.
 
Back
Top