concatenate where condition on openreport

C

csulbw

I am trying to set the 'where' condition in vb by concatenating two
variables. If a check box on my form is checked, I want the condition to be
as indicated in the first procedure of the If statement below. The
[mgmt_unit_code] field is a text value indicating an organizational section
in an agency. For example, [mgmt_unit_code] may be "aa" or "aaa" or "aab".
This allows "sub levels" of the organization with "aaa" and "aab" being
subordinate to "aa". I want to be able to pull a single level or include
"sub levels" depending on the check box (i.e. "aa" or "aa*"). I've done this
before on other occasions, but for some reason I'm having a slow brain
today...

If Forms!frmAvailRes!chkRollup = -1 Then
strRollup = "*"
DoCmd.OpenReport "rptAvailLaborNotZero", acPreview, , "[mgmt_unit_code]
like " & strMU & strRollup
Else
DoCmd.OpenReport "rptAvailLaborNotZero", acPreview, , "[mgmt_unit_code]
like " & strMU
End If

The second condition works fine, but the first condition tells me there is
an extra ")" in the expression??? All insight is deeply appreciated.
 
D

Duane Hookom

Try:
If Forms!frmAvailRes!chkRollup = -1 Then
strRollup = "*"
DoCmd.OpenReport "rptAvailLaborNotZero", acPreview, , _
"[mgmt_unit_code] like '" & strMU & strRollup & "'"
Else
DoCmd.OpenReport "rptAvailLaborNotZero", acPreview, , _
"[mgmt_unit_code] like '" & strMU & "'"
End If
 

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

Similar Threads


Top