combo choose 1 or many

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

Guest

Could you please help me get started, I'm just getting more confused, when I
read.

On a form, I have a combo box and a command button.
I need to be able to choose 1 or many from the combo box then click the
command for the results of the query.

Thank you
 
Sorry, this is what I have, but it only allows me to choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
 
You cannot choose more than one selection from a combo box. For this
capability, you need a List Box with the Multi Select property set to either
Simple or Extended. Once you have made the selections, the ItemsSelected
collection of the ListBox will contain a list of the selections.

Dan @BCBS said:
Sorry, this is what I have, but it only allows me to choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





Dan @BCBS said:
Could you please help me get started, I'm just getting more confused, when I
read.

On a form, I have a combo box and a command button.
I need to be able to choose 1 or many from the combo box then click the
command for the results of the query.

Thank you
 
Ok, I did that and I can select a list of items, but I get no return of
anything when I click it... Here is my code - please see my note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "' AND " &
stExpedited

If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





Klatuu said:
You cannot choose more than one selection from a combo box. For this
capability, you need a List Box with the Multi Select property set to either
Simple or Extended. Once you have made the selections, the ItemsSelected
collection of the ListBox will contain a list of the selections.

Dan @BCBS said:
Sorry, this is what I have, but it only allows me to choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





Dan @BCBS said:
Could you please help me get started, I'm just getting more confused, when I
read.

On a form, I have a combo box and a command button.
I need to be able to choose 1 or many from the combo box then click the
command for the results of the query.

Thank you
 
The "tick marks" would be correct provided [TR_EXPEDITED] is a boolean data
type.

I don't know what you mean by "get no return" With a list box, you have to
use the ItemsSelected collection and handle each selected item independantly.
Read up on the ItemsSelected property in VBA Help.

Dan @BCBS said:
Ok, I did that and I can select a list of items, but I get no return of
anything when I click it... Here is my code - please see my note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "' AND " &
stExpedited

If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





Klatuu said:
You cannot choose more than one selection from a combo box. For this
capability, you need a List Box with the Multi Select property set to either
Simple or Extended. Once you have made the selections, the ItemsSelected
collection of the ListBox will contain a list of the selections.

Dan @BCBS said:
Sorry, this is what I have, but it only allows me to choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

Could you please help me get started, I'm just getting more confused, when I
read.

On a form, I have a combo box and a command button.
I need to be able to choose 1 or many from the combo box then click the
command for the results of the query.

Thank you
 
Ok, although I learned alot from the reading, I still cannot get it to do
what I need.
Let me re-ask my question in it's simpliest form:
One command button.
Three Combo boxes.

Could you please show me the simpliest code, when I click the command
button, it returns the choices made from the 3 combo boxes.

If I can understand this I will be able to tweek it from there, for what I
need.

Thank you for the help.


Klatuu said:
The "tick marks" would be correct provided [TR_EXPEDITED] is a boolean data
type.

I don't know what you mean by "get no return" With a list box, you have to
use the ItemsSelected collection and handle each selected item independantly.
Read up on the ItemsSelected property in VBA Help.

Dan @BCBS said:
Ok, I did that and I can select a list of items, but I get no return of
anything when I click it... Here is my code - please see my note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "' AND " &
stExpedited

If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





Klatuu said:
You cannot choose more than one selection from a combo box. For this
capability, you need a List Box with the Multi Select property set to either
Simple or Extended. Once you have made the selections, the ItemsSelected
collection of the ListBox will contain a list of the selections.

:

Sorry, this is what I have, but it only allows me to choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

Could you please help me get started, I'm just getting more confused, when I
read.

On a form, I have a combo box and a command button.
I need to be able to choose 1 or many from the combo box then click the
command for the results of the query.

Thank you
 
I' having a little trouble understanding your code. I notice you are adding
stexpedited to more than one field. Can you tell me how stexpedited really
works. The syntax below has stExpedited after the word AND with no
comparision.
Another problem is you are adding " AND " to stLink Critera without knowing
whether you will be adding any other criteria.
If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited

Normally, if you are building a Where String it would be something like:

If Not IsNull(Me.FirstCombo) Then
strCriteria = "[SomeField] = '" & Me.FirstCombo & "'"
End If

If Not isNull(Me.SecondCombo) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[AnotherField] = "Me.SecondCombo"
End If


Dan @BCBS said:
Ok, although I learned alot from the reading, I still cannot get it to do
what I need.
Let me re-ask my question in it's simpliest form:
One command button.
Three Combo boxes.

Could you please show me the simpliest code, when I click the command
button, it returns the choices made from the 3 combo boxes.

If I can understand this I will be able to tweek it from there, for what I
need.

Thank you for the help.


Klatuu said:
The "tick marks" would be correct provided [TR_EXPEDITED] is a boolean data
type.

I don't know what you mean by "get no return" With a list box, you have to
use the ItemsSelected collection and handle each selected item independantly.
Read up on the ItemsSelected property in VBA Help.

Dan @BCBS said:
Ok, I did that and I can select a list of items, but I get no return of
anything when I click it... Here is my code - please see my note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "' AND " &
stExpedited

If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

You cannot choose more than one selection from a combo box. For this
capability, you need a List Box with the Multi Select property set to either
Simple or Extended. Once you have made the selections, the ItemsSelected
collection of the ListBox will contain a list of the selections.

:

Sorry, this is what I have, but it only allows me to choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

Could you please help me get started, I'm just getting more confused, when I
read.

On a form, I have a combo box and a command button.
I need to be able to choose 1 or many from the combo box then click the
command for the results of the query.

Thank you
 
You have me going in the right direction, but I am getting a data return of
all records, not just the ones specific to the combo boxes.
Here are the combinations I have tried:
A.
If Not (IsNull(Me.DecCode)) Then
stCriteria = "[TR_DECISION]='" & Me.DecCode & "'"
End If

If Not (IsNull(Me.cmbstatus)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[S_STATUS] = Me.cmbstatus"
End If

Results: I get results but not specific to the combo boxes..

B.
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]='" & Me.cmbstatus & "'"

End If
If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
strCriteria = "[TR_DECISION] = Me.DecCode"
End If
End If

Results: Same as A.



Klatuu said:
I' having a little trouble understanding your code. I notice you are adding
stexpedited to more than one field. Can you tell me how stexpedited really
works. The syntax below has stExpedited after the word AND with no
comparision.
Another problem is you are adding " AND " to stLink Critera without knowing
whether you will be adding any other criteria.
If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited

Normally, if you are building a Where String it would be something like:

If Not IsNull(Me.FirstCombo) Then
strCriteria = "[SomeField] = '" & Me.FirstCombo & "'"
End If

If Not isNull(Me.SecondCombo) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[AnotherField] = "Me.SecondCombo"
End If


Dan @BCBS said:
Ok, although I learned alot from the reading, I still cannot get it to do
what I need.
Let me re-ask my question in it's simpliest form:
One command button.
Three Combo boxes.

Could you please show me the simpliest code, when I click the command
button, it returns the choices made from the 3 combo boxes.

If I can understand this I will be able to tweek it from there, for what I
need.

Thank you for the help.


Klatuu said:
The "tick marks" would be correct provided [TR_EXPEDITED] is a boolean data
type.

I don't know what you mean by "get no return" With a list box, you have to
use the ItemsSelected collection and handle each selected item independantly.
Read up on the ItemsSelected property in VBA Help.

:

Ok, I did that and I can select a list of items, but I get no return of
anything when I click it... Here is my code - please see my note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "' AND " &
stExpedited

If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

You cannot choose more than one selection from a combo box. For this
capability, you need a List Box with the Multi Select property set to either
Simple or Extended. Once you have made the selections, the ItemsSelected
collection of the ListBox will contain a list of the selections.

:

Sorry, this is what I have, but it only allows me to choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

Could you please help me get started, I'm just getting more confused, when I
read.

On a form, I have a combo box and a command button.
I need to be able to choose 1 or many from the combo box then click the
command for the results of the query.

Thank you
 
Change " AND" to " AND " It should have a space after it.
Be sure [TR_DECISION] is a text field
Be sure [S_STATUS] is a numeric field

The other part is probably my fault. I used stCriteria, which you copied;
however, your open report may still be using stLinkCriteria. Be sure the
variable name you are using to build the Where string is the same you are
using in the OpenReport.

Dan @BCBS said:
You have me going in the right direction, but I am getting a data return of
all records, not just the ones specific to the combo boxes.
Here are the combinations I have tried:
A.
If Not (IsNull(Me.DecCode)) Then
stCriteria = "[TR_DECISION]='" & Me.DecCode & "'"
End If

If Not (IsNull(Me.cmbstatus)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[S_STATUS] = Me.cmbstatus"
End If

Results: I get results but not specific to the combo boxes..

B.
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]='" & Me.cmbstatus & "'"

End If
If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
strCriteria = "[TR_DECISION] = Me.DecCode"
End If
End If

Results: Same as A.



Klatuu said:
I' having a little trouble understanding your code. I notice you are adding
stexpedited to more than one field. Can you tell me how stexpedited really
works. The syntax below has stExpedited after the word AND with no
comparision.
Another problem is you are adding " AND " to stLink Critera without knowing
whether you will be adding any other criteria.
If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited

Normally, if you are building a Where String it would be something like:

If Not IsNull(Me.FirstCombo) Then
strCriteria = "[SomeField] = '" & Me.FirstCombo & "'"
End If

If Not isNull(Me.SecondCombo) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[AnotherField] = "Me.SecondCombo"
End If


Dan @BCBS said:
Ok, although I learned alot from the reading, I still cannot get it to do
what I need.
Let me re-ask my question in it's simpliest form:
One command button.
Three Combo boxes.

Could you please show me the simpliest code, when I click the command
button, it returns the choices made from the 3 combo boxes.

If I can understand this I will be able to tweek it from there, for what I
need.

Thank you for the help.


:

The "tick marks" would be correct provided [TR_EXPEDITED] is a boolean data
type.

I don't know what you mean by "get no return" With a list box, you have to
use the ItemsSelected collection and handle each selected item independantly.
Read up on the ItemsSelected property in VBA Help.

:

Ok, I did that and I can select a list of items, but I get no return of
anything when I click it... Here is my code - please see my note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "' AND " &
stExpedited

If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

You cannot choose more than one selection from a combo box. For this
capability, you need a List Box with the Multi Select property set to either
Simple or Extended. Once you have made the selections, the ItemsSelected
collection of the ListBox will contain a list of the selections.

:

Sorry, this is what I have, but it only allows me to choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

Could you please help me get started, I'm just getting more confused, when I
read.

On a form, I have a combo box and a command button.
I need to be able to choose 1 or many from the combo box then click the
command for the results of the query.

Thank you
 
1. I added the space after AND.
2. [TR_DECISION] and [S_STATUS] are both text fields.
3. I had noticed the stCriteria and changed it in the OpenReport.

The first IF works fine, even if I change the fields to decision, I will get
the correct decision:
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]= '" & Me.cmbstatus & "'

The problem seems to be in the second IF, the results completly ecnore this
combo box and the return is all of them.

If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND "
strCriteria = "[TR_DECISION] = Me.DecCode"

HELP







Klatuu said:
Change " AND" to " AND " It should have a space after it.
Be sure [TR_DECISION] is a text field
Be sure [S_STATUS] is a numeric field

The other part is probably my fault. I used stCriteria, which you copied;
however, your open report may still be using stLinkCriteria. Be sure the
variable name you are using to build the Where string is the same you are
using in the OpenReport.

Dan @BCBS said:
You have me going in the right direction, but I am getting a data return of
all records, not just the ones specific to the combo boxes.
Here are the combinations I have tried:
A.
If Not (IsNull(Me.DecCode)) Then
stCriteria = "[TR_DECISION]='" & Me.DecCode & "'"
End If

If Not (IsNull(Me.cmbstatus)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[S_STATUS] = Me.cmbstatus"
End If

Results: I get results but not specific to the combo boxes..

B.
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]='" & Me.cmbstatus & "'"

End If
If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
strCriteria = "[TR_DECISION] = Me.DecCode"
End If
End If

Results: Same as A.



Klatuu said:
I' having a little trouble understanding your code. I notice you are adding
stexpedited to more than one field. Can you tell me how stexpedited really
works. The syntax below has stExpedited after the word AND with no
comparision.
Another problem is you are adding " AND " to stLink Critera without knowing
whether you will be adding any other criteria.
If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited

Normally, if you are building a Where String it would be something like:

If Not IsNull(Me.FirstCombo) Then
strCriteria = "[SomeField] = '" & Me.FirstCombo & "'"
End If

If Not isNull(Me.SecondCombo) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[AnotherField] = "Me.SecondCombo"
End If


:

Ok, although I learned alot from the reading, I still cannot get it to do
what I need.
Let me re-ask my question in it's simpliest form:
One command button.
Three Combo boxes.

Could you please show me the simpliest code, when I click the command
button, it returns the choices made from the 3 combo boxes.

If I can understand this I will be able to tweek it from there, for what I
need.

Thank you for the help.


:

The "tick marks" would be correct provided [TR_EXPEDITED] is a boolean data
type.

I don't know what you mean by "get no return" With a list box, you have to
use the ItemsSelected collection and handle each selected item independantly.
Read up on the ItemsSelected property in VBA Help.

:

Ok, I did that and I can select a list of items, but I get no return of
anything when I click it... Here is my code - please see my note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "' AND " &
stExpedited

If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

You cannot choose more than one selection from a combo box. For this
capability, you need a List Box with the Multi Select property set to either
Simple or Extended. Once you have made the selections, the ItemsSelected
collection of the ListBox will contain a list of the selections.

:

Sorry, this is what I have, but it only allows me to choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

Could you please help me get started, I'm just getting more confused, when I
read.

On a form, I have a combo box and a command button.
I need to be able to choose 1 or many from the combo box then click the
command for the results of the query.

Thank you
 
The last statement needs to be:

strCriteria = strCriteria & "[TR_DECISION] = Me.DecCode"


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dan @BCBS said:
1. I added the space after AND.
2. [TR_DECISION] and [S_STATUS] are both text fields.
3. I had noticed the stCriteria and changed it in the OpenReport.

The first IF works fine, even if I change the fields to decision, I will get
the correct decision:
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]= '" & Me.cmbstatus & "'

The problem seems to be in the second IF, the results completly ecnore this
combo box and the return is all of them.

If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND "
strCriteria = "[TR_DECISION] = Me.DecCode"

HELP







Klatuu said:
Change " AND" to " AND " It should have a space after it.
Be sure [TR_DECISION] is a text field
Be sure [S_STATUS] is a numeric field

The other part is probably my fault. I used stCriteria, which you copied;
however, your open report may still be using stLinkCriteria. Be sure the
variable name you are using to build the Where string is the same you are
using in the OpenReport.

Dan @BCBS said:
You have me going in the right direction, but I am getting a data return of
all records, not just the ones specific to the combo boxes.
Here are the combinations I have tried:
A.
If Not (IsNull(Me.DecCode)) Then
stCriteria = "[TR_DECISION]='" & Me.DecCode & "'"
End If

If Not (IsNull(Me.cmbstatus)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[S_STATUS] = Me.cmbstatus"
End If

Results: I get results but not specific to the combo boxes..

B.
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]='" & Me.cmbstatus & "'"

End If
If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
strCriteria = "[TR_DECISION] = Me.DecCode"
End If
End If

Results: Same as A.



:

I' having a little trouble understanding your code. I notice you are adding
stexpedited to more than one field. Can you tell me how stexpedited really
works. The syntax below has stExpedited after the word AND with no
comparision.
Another problem is you are adding " AND " to stLink Critera without knowing
whether you will be adding any other criteria.
If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited

Normally, if you are building a Where String it would be something like:

If Not IsNull(Me.FirstCombo) Then
strCriteria = "[SomeField] = '" & Me.FirstCombo & "'"
End If

If Not isNull(Me.SecondCombo) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[AnotherField] = "Me.SecondCombo"
End If


:

Ok, although I learned alot from the reading, I still cannot get it to do
what I need.
Let me re-ask my question in it's simpliest form:
One command button.
Three Combo boxes.

Could you please show me the simpliest code, when I click the command
button, it returns the choices made from the 3 combo boxes.

If I can understand this I will be able to tweek it from there, for what I
need.

Thank you for the help.


:

The "tick marks" would be correct provided [TR_EXPEDITED] is a boolean data
type.

I don't know what you mean by "get no return" With a list box, you have to
use the ItemsSelected collection and handle each selected item independantly.
Read up on the ItemsSelected property in VBA Help.

:

Ok, I did that and I can select a list of items, but I get no return of
anything when I click it... Here is my code - please see my note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "' AND " &
stExpedited

If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

You cannot choose more than one selection from a combo box. For this
capability, you need a List Box with the Multi Select property set to either
Simple or Extended. Once you have made the selections, the ItemsSelected
collection of the ListBox will contain a list of the selections.

:

Sorry, this is what I have, but it only allows me to choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

Could you please help me get started, I'm just getting more confused, when I
read.

On a form, I have a combo box and a command button.
I need to be able to choose 1 or many from the combo box then click the
command for the results of the query.

Thank you
 
If both are text fields, they need to be enclosed in quotes.
stCriteria = "[TR_DECISION]='" & Me.DecCode & "'"
stCriteria = "[TR_STATUS]= '" & Me.cmbstatus & "'"

The where condition for OpenReport and OpenForm and all Domain Aggragate
functions are really SQL and follow these rules for passing the parameters:

Text - Enclose in single or double quotes ' or "
Date - Enclose in pound signs #
Numeric - No Enclosure.
Dan @BCBS said:
1. I added the space after AND.
2. [TR_DECISION] and [S_STATUS] are both text fields.
3. I had noticed the stCriteria and changed it in the OpenReport.

The first IF works fine, even if I change the fields to decision, I will get
the correct decision:
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]= '" & Me.cmbstatus & "'

The problem seems to be in the second IF, the results completly ecnore this
combo box and the return is all of them.

If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND "
strCriteria = "[TR_DECISION] = Me.DecCode"

HELP







Klatuu said:
Change " AND" to " AND " It should have a space after it.
Be sure [TR_DECISION] is a text field
Be sure [S_STATUS] is a numeric field

The other part is probably my fault. I used stCriteria, which you copied;
however, your open report may still be using stLinkCriteria. Be sure the
variable name you are using to build the Where string is the same you are
using in the OpenReport.

Dan @BCBS said:
You have me going in the right direction, but I am getting a data return of
all records, not just the ones specific to the combo boxes.
Here are the combinations I have tried:
A.
If Not (IsNull(Me.DecCode)) Then
stCriteria = "[TR_DECISION]='" & Me.DecCode & "'"
End If

If Not (IsNull(Me.cmbstatus)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[S_STATUS] = Me.cmbstatus"
End If

Results: I get results but not specific to the combo boxes..

B.
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]='" & Me.cmbstatus & "'"

End If
If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
strCriteria = "[TR_DECISION] = Me.DecCode"
End If
End If

Results: Same as A.



:

I' having a little trouble understanding your code. I notice you are adding
stexpedited to more than one field. Can you tell me how stexpedited really
works. The syntax below has stExpedited after the word AND with no
comparision.
Another problem is you are adding " AND " to stLink Critera without knowing
whether you will be adding any other criteria.
If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited

Normally, if you are building a Where String it would be something like:

If Not IsNull(Me.FirstCombo) Then
strCriteria = "[SomeField] = '" & Me.FirstCombo & "'"
End If

If Not isNull(Me.SecondCombo) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[AnotherField] = "Me.SecondCombo"
End If


:

Ok, although I learned alot from the reading, I still cannot get it to do
what I need.
Let me re-ask my question in it's simpliest form:
One command button.
Three Combo boxes.

Could you please show me the simpliest code, when I click the command
button, it returns the choices made from the 3 combo boxes.

If I can understand this I will be able to tweek it from there, for what I
need.

Thank you for the help.


:

The "tick marks" would be correct provided [TR_EXPEDITED] is a boolean data
type.

I don't know what you mean by "get no return" With a list box, you have to
use the ItemsSelected collection and handle each selected item independantly.
Read up on the ItemsSelected property in VBA Help.

:

Ok, I did that and I can select a list of items, but I get no return of
anything when I click it... Here is my code - please see my note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "' AND " &
stExpedited

If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

You cannot choose more than one selection from a combo box. For this
capability, you need a List Box with the Multi Select property set to either
Simple or Extended. Once you have made the selections, the ItemsSelected
collection of the ListBox will contain a list of the selections.

:

Sorry, this is what I have, but it only allows me to choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

Could you please help me get started, I'm just getting more confused, when I
read.

On a form, I have a combo box and a command button.
I need to be able to choose 1 or many from the combo box then click the
command for the results of the query.

Thank you
 
Caught my typo, thanks, actually, it is text and should be:

strCriteria = strCriteria & "[TR_DECISION] = '" & Me.DecCode & "'"


Douglas J Steele said:
The last statement needs to be:

strCriteria = strCriteria & "[TR_DECISION] = Me.DecCode"


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dan @BCBS said:
1. I added the space after AND.
2. [TR_DECISION] and [S_STATUS] are both text fields.
3. I had noticed the stCriteria and changed it in the OpenReport.

The first IF works fine, even if I change the fields to decision, I will get
the correct decision:
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]= '" & Me.cmbstatus & "'

The problem seems to be in the second IF, the results completly ecnore this
combo box and the return is all of them.

If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND "
strCriteria = "[TR_DECISION] = Me.DecCode"

HELP







Klatuu said:
Change " AND" to " AND " It should have a space after it.
Be sure [TR_DECISION] is a text field
Be sure [S_STATUS] is a numeric field

The other part is probably my fault. I used stCriteria, which you copied;
however, your open report may still be using stLinkCriteria. Be sure the
variable name you are using to build the Where string is the same you are
using in the OpenReport.

:

You have me going in the right direction, but I am getting a data return of
all records, not just the ones specific to the combo boxes.
Here are the combinations I have tried:
A.
If Not (IsNull(Me.DecCode)) Then
stCriteria = "[TR_DECISION]='" & Me.DecCode & "'"
End If

If Not (IsNull(Me.cmbstatus)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[S_STATUS] = Me.cmbstatus"
End If

Results: I get results but not specific to the combo boxes..

B.
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]='" & Me.cmbstatus & "'"

End If
If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
strCriteria = "[TR_DECISION] = Me.DecCode"
End If
End If

Results: Same as A.



:

I' having a little trouble understanding your code. I notice you are adding
stexpedited to more than one field. Can you tell me how stexpedited really
works. The syntax below has stExpedited after the word AND with no
comparision.
Another problem is you are adding " AND " to stLink Critera without knowing
whether you will be adding any other criteria.
If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited

Normally, if you are building a Where String it would be something like:

If Not IsNull(Me.FirstCombo) Then
strCriteria = "[SomeField] = '" & Me.FirstCombo & "'"
End If

If Not isNull(Me.SecondCombo) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[AnotherField] = "Me.SecondCombo"
End If


:

Ok, although I learned alot from the reading, I still cannot get it to do
what I need.
Let me re-ask my question in it's simpliest form:
One command button.
Three Combo boxes.

Could you please show me the simpliest code, when I click the command
button, it returns the choices made from the 3 combo boxes.

If I can understand this I will be able to tweek it from there, for what I
need.

Thank you for the help.


:

The "tick marks" would be correct provided [TR_EXPEDITED] is a boolean data
type.

I don't know what you mean by "get no return" With a list box, you have to
use the ItemsSelected collection and handle each selected item independantly.
Read up on the ItemsSelected property in VBA Help.

:

Ok, I did that and I can select a list of items, but I get no return of
anything when I click it... Here is my code - please see my note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "' AND " &
stExpedited

If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

You cannot choose more than one selection from a combo box. For this
capability, you need a List Box with the Multi Select property set to either
Simple or Extended. Once you have made the selections, the ItemsSelected
collection of the ListBox will contain a list of the selections.

:

Sorry, this is what I have, but it only allows me to choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

Could you please help me get started, I'm just getting more confused, when I
read.

On a form, I have a combo box and a command button.
I need to be able to choose 1 or many from the combo box then click the
command for the results of the query.

Thank you
 
I think I'm 99% there - this code returns data based on the answer to the two
combo boxes. BUT, it does not consider the answer to the MsgBox.

The DoCmd shows everything for "stCriteria" but how do I include the
"stExpedited"

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_Status]= '" & Me.cmbstatus & "'"

If Not (IsNull(Me.DecCode)) Then
If Len(stCriteria) > 0 Then
stCriteria = stCriteria & " AND "
stCriteria = stCriteria & "[TR_DECISION]= '" & Me.DecCode & "'"
End If
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stCriteria



Klatuu said:
Caught my typo, thanks, actually, it is text and should be:

strCriteria = strCriteria & "[TR_DECISION] = '" & Me.DecCode & "'"


Douglas J Steele said:
The last statement needs to be:

strCriteria = strCriteria & "[TR_DECISION] = Me.DecCode"


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dan @BCBS said:
1. I added the space after AND.
2. [TR_DECISION] and [S_STATUS] are both text fields.
3. I had noticed the stCriteria and changed it in the OpenReport.

The first IF works fine, even if I change the fields to decision, I will get
the correct decision:
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]= '" & Me.cmbstatus & "'

The problem seems to be in the second IF, the results completly ecnore this
combo box and the return is all of them.

If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND "
strCriteria = "[TR_DECISION] = Me.DecCode"

HELP







:

Change " AND" to " AND " It should have a space after it.
Be sure [TR_DECISION] is a text field
Be sure [S_STATUS] is a numeric field

The other part is probably my fault. I used stCriteria, which you copied;
however, your open report may still be using stLinkCriteria. Be sure the
variable name you are using to build the Where string is the same you are
using in the OpenReport.

:

You have me going in the right direction, but I am getting a data return of
all records, not just the ones specific to the combo boxes.
Here are the combinations I have tried:
A.
If Not (IsNull(Me.DecCode)) Then
stCriteria = "[TR_DECISION]='" & Me.DecCode & "'"
End If

If Not (IsNull(Me.cmbstatus)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[S_STATUS] = Me.cmbstatus"
End If

Results: I get results but not specific to the combo boxes..

B.
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]='" & Me.cmbstatus & "'"

End If
If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
strCriteria = "[TR_DECISION] = Me.DecCode"
End If
End If

Results: Same as A.



:

I' having a little trouble understanding your code. I notice you are adding
stexpedited to more than one field. Can you tell me how stexpedited really
works. The syntax below has stExpedited after the word AND with no
comparision.
Another problem is you are adding " AND " to stLink Critera without knowing
whether you will be adding any other criteria.
If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited

Normally, if you are building a Where String it would be something like:

If Not IsNull(Me.FirstCombo) Then
strCriteria = "[SomeField] = '" & Me.FirstCombo & "'"
End If

If Not isNull(Me.SecondCombo) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[AnotherField] = "Me.SecondCombo"
End If


:

Ok, although I learned alot from the reading, I still cannot get it to do
what I need.
Let me re-ask my question in it's simpliest form:
One command button.
Three Combo boxes.

Could you please show me the simpliest code, when I click the command
button, it returns the choices made from the 3 combo boxes.

If I can understand this I will be able to tweek it from there, for what I
need.

Thank you for the help.


:

The "tick marks" would be correct provided [TR_EXPEDITED] is a boolean data
type.

I don't know what you mean by "get no return" With a list box, you have to
use the ItemsSelected collection and handle each selected item independantly.
Read up on the ItemsSelected property in VBA Help.

:

Ok, I did that and I can select a list of items, but I get no return of
anything when I click it... Here is my code - please see my note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "' AND " &
stExpedited

If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

You cannot choose more than one selection from a combo box. For this
capability, you need a List Box with the Multi Select property set to either
Simple or Extended. Once you have made the selections, the ItemsSelected
collection of the ListBox will contain a list of the selections.

:

Sorry, this is what I have, but it only allows me to choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

Could you please help me get started, I'm just getting more confused, when I
read.

On a form, I have a combo box and a command button.
I need to be able to choose 1 or many from the combo box then click the
command for the results of the query.

Thank you
 
First, it is not included in stCriteria
Second, you need to make changes to your code to keep values outside the
quotes.
Third, Be sure that [TR_EXPEDITED] is a Yes/No field in your table.
And, you need to add it to strCriteria

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]= " & True
Else
stExpedited = "[TR_EXPEDITED]= " & False
End If

Now, after you have built the other criteria, just before you open the report"

If len(stCrtiteria) > 0 Then
stCriteria = strCriteria & " AND "
End If

strCriteria = strCriteria & stExpedited

Dan @BCBS said:
I think I'm 99% there - this code returns data based on the answer to the two
combo boxes. BUT, it does not consider the answer to the MsgBox.

The DoCmd shows everything for "stCriteria" but how do I include the
"stExpedited"

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_Status]= '" & Me.cmbstatus & "'"

If Not (IsNull(Me.DecCode)) Then
If Len(stCriteria) > 0 Then
stCriteria = stCriteria & " AND "
stCriteria = stCriteria & "[TR_DECISION]= '" & Me.DecCode & "'"
End If
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stCriteria



Klatuu said:
Caught my typo, thanks, actually, it is text and should be:

strCriteria = strCriteria & "[TR_DECISION] = '" & Me.DecCode & "'"


Douglas J Steele said:
The last statement needs to be:

strCriteria = strCriteria & "[TR_DECISION] = Me.DecCode"


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


1. I added the space after AND.
2. [TR_DECISION] and [S_STATUS] are both text fields.
3. I had noticed the stCriteria and changed it in the OpenReport.

The first IF works fine, even if I change the fields to decision, I will
get
the correct decision:
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]= '" & Me.cmbstatus & "'

The problem seems to be in the second IF, the results completly ecnore
this
combo box and the return is all of them.

If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND "
strCriteria = "[TR_DECISION] = Me.DecCode"

HELP







:

Change " AND" to " AND " It should have a space after it.
Be sure [TR_DECISION] is a text field
Be sure [S_STATUS] is a numeric field

The other part is probably my fault. I used stCriteria, which you
copied;
however, your open report may still be using stLinkCriteria. Be sure
the
variable name you are using to build the Where string is the same you
are
using in the OpenReport.

:

You have me going in the right direction, but I am getting a data
return of
all records, not just the ones specific to the combo boxes.
Here are the combinations I have tried:
A.
If Not (IsNull(Me.DecCode)) Then
stCriteria = "[TR_DECISION]='" & Me.DecCode & "'"
End If

If Not (IsNull(Me.cmbstatus)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[S_STATUS] = Me.cmbstatus"
End If

Results: I get results but not specific to the combo boxes..

B.
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]='" & Me.cmbstatus & "'"

End If
If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
strCriteria = "[TR_DECISION] = Me.DecCode"
End If
End If

Results: Same as A.



:

I' having a little trouble understanding your code. I notice you
are adding
stexpedited to more than one field. Can you tell me how stexpedited
really
works. The syntax below has stExpedited after the word AND with no
comparision.
Another problem is you are adding " AND " to stLink Critera without
knowing
whether you will be adding any other criteria.
If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND
"
& stExpedited

Normally, if you are building a Where String it would be something
like:

If Not IsNull(Me.FirstCombo) Then
strCriteria = "[SomeField] = '" & Me.FirstCombo & "'"
End If

If Not isNull(Me.SecondCombo) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[AnotherField] = "Me.SecondCombo"
End If


:

Ok, although I learned alot from the reading, I still cannot get
it to do
what I need.
Let me re-ask my question in it's simpliest form:
One command button.
Three Combo boxes.

Could you please show me the simpliest code, when I click the
command
button, it returns the choices made from the 3 combo boxes.

If I can understand this I will be able to tweek it from there,
for what I
need.

Thank you for the help.


:

The "tick marks" would be correct provided [TR_EXPEDITED] is a
boolean data
type.

I don't know what you mean by "get no return" With a list box,
you have to
use the ItemsSelected collection and handle each selected item
independantly.
Read up on the ItemsSelected property in VBA Help.

:

Ok, I did that and I can select a list of items, but I get no
return of
anything when I click it... Here is my code - please see my
note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo,
"Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" &
Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for
status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "'
AND " &
stExpedited

If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode &
"' AND " &
stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

You cannot choose more than one selection from a combo box.
For this
capability, you need a List Box with the Multi Select
property set to either
Simple or Extended. Once you have made the selections, the
ItemsSelected
collection of the ListBox will contain a list of the
selections.

:

Sorry, this is what I have, but it only allows me to
choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" &
Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" &
Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, ,
stLinkCriteria





:

Could you please help me get started, I'm just getting
more confused, when I
read.

On a form, I have a combo box and a command button.
I need to be able to choose 1 or many from the combo box
then click the
command for the results of the query.

Thank you
 
Fantastic
But I have one last question: I also need to see all the data if both combo
boxes are left blank. Presently, if they are left blank there is no data is
returned.

I cannot thank you enough, I have three databases that have been in need if
this capability..


This is the code I have, which has no data return if combo boxes are blank.

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=" & True
Else
stExpedited = "[TR_EXPEDITED]=" & False
End If

If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_Status]= '" & Me.cmbstatus & "'"

If Not (IsNull(Me.DecCode)) Then
If Len(stCriteria) > 0 Then
stCriteria = stCriteria & " AND "
stCriteria = stCriteria & "[TR_DECISION]= '" & Me.DecCode & "'"
End If
End If

If Len(stCriteria) > 0 Then
stCriteria = stCriteria & " AND "
stCriteria = stCriteria & stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stCriteria



Klatuu said:
First, it is not included in stCriteria
Second, you need to make changes to your code to keep values outside the
quotes.
Third, Be sure that [TR_EXPEDITED] is a Yes/No field in your table.
And, you need to add it to strCriteria

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]= " & True
Else
stExpedited = "[TR_EXPEDITED]= " & False
End If

Now, after you have built the other criteria, just before you open the report"

If len(stCrtiteria) > 0 Then
stCriteria = strCriteria & " AND "
End If

strCriteria = strCriteria & stExpedited

Dan @BCBS said:
I think I'm 99% there - this code returns data based on the answer to the two
combo boxes. BUT, it does not consider the answer to the MsgBox.

The DoCmd shows everything for "stCriteria" but how do I include the
"stExpedited"

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_Status]= '" & Me.cmbstatus & "'"

If Not (IsNull(Me.DecCode)) Then
If Len(stCriteria) > 0 Then
stCriteria = stCriteria & " AND "
stCriteria = stCriteria & "[TR_DECISION]= '" & Me.DecCode & "'"
End If
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stCriteria



Klatuu said:
Caught my typo, thanks, actually, it is text and should be:

strCriteria = strCriteria & "[TR_DECISION] = '" & Me.DecCode & "'"


:

The last statement needs to be:

strCriteria = strCriteria & "[TR_DECISION] = Me.DecCode"


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


1. I added the space after AND.
2. [TR_DECISION] and [S_STATUS] are both text fields.
3. I had noticed the stCriteria and changed it in the OpenReport.

The first IF works fine, even if I change the fields to decision, I will
get
the correct decision:
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]= '" & Me.cmbstatus & "'

The problem seems to be in the second IF, the results completly ecnore
this
combo box and the return is all of them.

If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND "
strCriteria = "[TR_DECISION] = Me.DecCode"

HELP







:

Change " AND" to " AND " It should have a space after it.
Be sure [TR_DECISION] is a text field
Be sure [S_STATUS] is a numeric field

The other part is probably my fault. I used stCriteria, which you
copied;
however, your open report may still be using stLinkCriteria. Be sure
the
variable name you are using to build the Where string is the same you
are
using in the OpenReport.

:

You have me going in the right direction, but I am getting a data
return of
all records, not just the ones specific to the combo boxes.
Here are the combinations I have tried:
A.
If Not (IsNull(Me.DecCode)) Then
stCriteria = "[TR_DECISION]='" & Me.DecCode & "'"
End If

If Not (IsNull(Me.cmbstatus)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[S_STATUS] = Me.cmbstatus"
End If

Results: I get results but not specific to the combo boxes..

B.
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]='" & Me.cmbstatus & "'"

End If
If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
strCriteria = "[TR_DECISION] = Me.DecCode"
End If
End If

Results: Same as A.



:

I' having a little trouble understanding your code. I notice you
are adding
stexpedited to more than one field. Can you tell me how stexpedited
really
works. The syntax below has stExpedited after the word AND with no
comparision.
Another problem is you are adding " AND " to stLink Critera without
knowing
whether you will be adding any other criteria.
If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND
"
& stExpedited

Normally, if you are building a Where String it would be something
like:

If Not IsNull(Me.FirstCombo) Then
strCriteria = "[SomeField] = '" & Me.FirstCombo & "'"
End If

If Not isNull(Me.SecondCombo) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[AnotherField] = "Me.SecondCombo"
End If


:

Ok, although I learned alot from the reading, I still cannot get
it to do
what I need.
Let me re-ask my question in it's simpliest form:
One command button.
Three Combo boxes.

Could you please show me the simpliest code, when I click the
command
button, it returns the choices made from the 3 combo boxes.

If I can understand this I will be able to tweek it from there,
for what I
need.

Thank you for the help.


:

The "tick marks" would be correct provided [TR_EXPEDITED] is a
boolean data
type.

I don't know what you mean by "get no return" With a list box,
you have to
use the ItemsSelected collection and handle each selected item
independantly.
Read up on the ItemsSelected property in VBA Help.

:

Ok, I did that and I can select a list of items, but I get no
return of
anything when I click it... Here is my code - please see my
note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo,
"Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" &
Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for
status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "'
AND " &
stExpedited

If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode &
"' AND " &
stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria





:

You cannot choose more than one selection from a combo box.
For this
capability, you need a List Box with the Multi Select
property set to either
Simple or Extended. Once you have made the selections, the
ItemsSelected
collection of the ListBox will contain a list of the
selections.

:

Sorry, this is what I have, but it only allows me to
choose one from the
combo box...

If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" &
Me.InqType & "' AND " &
stExpedited


If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" &
Me.DecCode & "' AND " &
stExpedited


End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, ,
stLinkCriteria
 
See below where one End If was out of place which was causing it to skip
looking at DecCode if cmbStatus was Null.

Reviewing your code, you are ony building criterai for DecCode and cmdStatus
if they are not Null. It will always filter on expedited, So, they way it is
now should return all records for either expedited = True or expedited =
False if nothing is in either of the combo boxes. Are you saying that is
not happening?

Dan @BCBS said:
Fantastic
But I have one last question: I also need to see all the data if both combo
boxes are left blank. Presently, if they are left blank there is no data is
returned.

I cannot thank you enough, I have three databases that have been in need if
this capability..


This is the code I have, which has no data return if combo boxes are blank.

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=" & True
Else
stExpedited = "[TR_EXPEDITED]=" & False
End If

If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_Status]= '" & Me.cmbstatus & "'"
End If

If Not (IsNull(Me.DecCode)) Then
If Len(stCriteria) > 0 Then
stCriteria = stCriteria & " AND "
stCriteria = stCriteria & "[TR_DECISION]= '" & Me.DecCode & "'"
End If

If Len(stCriteria) > 0 Then
stCriteria = stCriteria & " AND "
stCriteria = stCriteria & stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stCriteria



Klatuu said:
First, it is not included in stCriteria
Second, you need to make changes to your code to keep values outside the
quotes.
Third, Be sure that [TR_EXPEDITED] is a Yes/No field in your table.
And, you need to add it to strCriteria

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]= " & True
Else
stExpedited = "[TR_EXPEDITED]= " & False
End If

Now, after you have built the other criteria, just before you open the report"

If len(stCrtiteria) > 0 Then
stCriteria = strCriteria & " AND "
End If

strCriteria = strCriteria & stExpedited

Dan @BCBS said:
I think I'm 99% there - this code returns data based on the answer to the two
combo boxes. BUT, it does not consider the answer to the MsgBox.

The DoCmd shows everything for "stCriteria" but how do I include the
"stExpedited"

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_Status]= '" & Me.cmbstatus & "'"

If Not (IsNull(Me.DecCode)) Then
If Len(stCriteria) > 0 Then
stCriteria = stCriteria & " AND "
stCriteria = stCriteria & "[TR_DECISION]= '" & Me.DecCode & "'"
End If
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stCriteria



:

Caught my typo, thanks, actually, it is text and should be:

strCriteria = strCriteria & "[TR_DECISION] = '" & Me.DecCode & "'"


:

The last statement needs to be:

strCriteria = strCriteria & "[TR_DECISION] = Me.DecCode"


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


1. I added the space after AND.
2. [TR_DECISION] and [S_STATUS] are both text fields.
3. I had noticed the stCriteria and changed it in the OpenReport.

The first IF works fine, even if I change the fields to decision, I will
get
the correct decision:
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]= '" & Me.cmbstatus & "'

The problem seems to be in the second IF, the results completly ecnore
this
combo box and the return is all of them.

If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND "
strCriteria = "[TR_DECISION] = Me.DecCode"

HELP







:

Change " AND" to " AND " It should have a space after it.
Be sure [TR_DECISION] is a text field
Be sure [S_STATUS] is a numeric field

The other part is probably my fault. I used stCriteria, which you
copied;
however, your open report may still be using stLinkCriteria. Be sure
the
variable name you are using to build the Where string is the same you
are
using in the OpenReport.

:

You have me going in the right direction, but I am getting a data
return of
all records, not just the ones specific to the combo boxes.
Here are the combinations I have tried:
A.
If Not (IsNull(Me.DecCode)) Then
stCriteria = "[TR_DECISION]='" & Me.DecCode & "'"
End If

If Not (IsNull(Me.cmbstatus)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[S_STATUS] = Me.cmbstatus"
End If

Results: I get results but not specific to the combo boxes..

B.
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]='" & Me.cmbstatus & "'"

End If
If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
strCriteria = "[TR_DECISION] = Me.DecCode"
End If
End If

Results: Same as A.



:

I' having a little trouble understanding your code. I notice you
are adding
stexpedited to more than one field. Can you tell me how stexpedited
really
works. The syntax below has stExpedited after the word AND with no
comparision.
Another problem is you are adding " AND " to stLink Critera without
knowing
whether you will be adding any other criteria.
If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND
"
& stExpedited

Normally, if you are building a Where String it would be something
like:

If Not IsNull(Me.FirstCombo) Then
strCriteria = "[SomeField] = '" & Me.FirstCombo & "'"
End If

If Not isNull(Me.SecondCombo) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[AnotherField] = "Me.SecondCombo"
End If


:

Ok, although I learned alot from the reading, I still cannot get
it to do
what I need.
Let me re-ask my question in it's simpliest form:
One command button.
Three Combo boxes.

Could you please show me the simpliest code, when I click the
command
button, it returns the choices made from the 3 combo boxes.

If I can understand this I will be able to tweek it from there,
for what I
need.

Thank you for the help.


:

The "tick marks" would be correct provided [TR_EXPEDITED] is a
boolean data
type.

I don't know what you mean by "get no return" With a list box,
you have to
use the ItemsSelected collection and handle each selected item
independantly.
Read up on the ItemsSelected property in VBA Help.

:

Ok, I did that and I can select a list of items, but I get no
return of
anything when I click it... Here is my code - please see my
note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo,
"Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" &
Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for
status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "'
AND " &
stExpedited

If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode &
"' AND " &
stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
 
BINGO - BINGO - BINGO

You have now idea how much I needed to be taught this.
Thanks




Klatuu said:
See below where one End If was out of place which was causing it to skip
looking at DecCode if cmbStatus was Null.

Reviewing your code, you are ony building criterai for DecCode and cmdStatus
if they are not Null. It will always filter on expedited, So, they way it is
now should return all records for either expedited = True or expedited =
False if nothing is in either of the combo boxes. Are you saying that is
not happening?

Dan @BCBS said:
Fantastic
But I have one last question: I also need to see all the data if both combo
boxes are left blank. Presently, if they are left blank there is no data is
returned.

I cannot thank you enough, I have three databases that have been in need if
this capability..


This is the code I have, which has no data return if combo boxes are blank.

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=" & True
Else
stExpedited = "[TR_EXPEDITED]=" & False
End If

If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_Status]= '" & Me.cmbstatus & "'"
End If

If Not (IsNull(Me.DecCode)) Then
If Len(stCriteria) > 0 Then
stCriteria = stCriteria & " AND "
stCriteria = stCriteria & "[TR_DECISION]= '" & Me.DecCode & "'"
End If

If Len(stCriteria) > 0 Then
stCriteria = stCriteria & " AND "
stCriteria = stCriteria & stExpedited
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stCriteria



Klatuu said:
First, it is not included in stCriteria
Second, you need to make changes to your code to keep values outside the
quotes.
Third, Be sure that [TR_EXPEDITED] is a Yes/No field in your table.
And, you need to add it to strCriteria

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]= " & True
Else
stExpedited = "[TR_EXPEDITED]= " & False
End If

Now, after you have built the other criteria, just before you open the report"

If len(stCrtiteria) > 0 Then
stCriteria = strCriteria & " AND "
End If

strCriteria = strCriteria & stExpedited

:

I think I'm 99% there - this code returns data based on the answer to the two
combo boxes. BUT, it does not consider the answer to the MsgBox.

The DoCmd shows everything for "stCriteria" but how do I include the
"stExpedited"

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo, "Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_Status]= '" & Me.cmbstatus & "'"

If Not (IsNull(Me.DecCode)) Then
If Len(stCriteria) > 0 Then
stCriteria = stCriteria & " AND "
stCriteria = stCriteria & "[TR_DECISION]= '" & Me.DecCode & "'"
End If
End If

stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stCriteria



:

Caught my typo, thanks, actually, it is text and should be:

strCriteria = strCriteria & "[TR_DECISION] = '" & Me.DecCode & "'"


:

The last statement needs to be:

strCriteria = strCriteria & "[TR_DECISION] = Me.DecCode"


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


1. I added the space after AND.
2. [TR_DECISION] and [S_STATUS] are both text fields.
3. I had noticed the stCriteria and changed it in the OpenReport.

The first IF works fine, even if I change the fields to decision, I will
get
the correct decision:
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]= '" & Me.cmbstatus & "'

The problem seems to be in the second IF, the results completly ecnore
this
combo box and the return is all of them.

If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND "
strCriteria = "[TR_DECISION] = Me.DecCode"

HELP







:

Change " AND" to " AND " It should have a space after it.
Be sure [TR_DECISION] is a text field
Be sure [S_STATUS] is a numeric field

The other part is probably my fault. I used stCriteria, which you
copied;
however, your open report may still be using stLinkCriteria. Be sure
the
variable name you are using to build the Where string is the same you
are
using in the OpenReport.

:

You have me going in the right direction, but I am getting a data
return of
all records, not just the ones specific to the combo boxes.
Here are the combinations I have tried:
A.
If Not (IsNull(Me.DecCode)) Then
stCriteria = "[TR_DECISION]='" & Me.DecCode & "'"
End If

If Not (IsNull(Me.cmbstatus)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[S_STATUS] = Me.cmbstatus"
End If

Results: I get results but not specific to the combo boxes..

B.
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]='" & Me.cmbstatus & "'"

End If
If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
strCriteria = "[TR_DECISION] = Me.DecCode"
End If
End If

Results: Same as A.



:

I' having a little trouble understanding your code. I notice you
are adding
stexpedited to more than one field. Can you tell me how stexpedited
really
works. The syntax below has stExpedited after the word AND with no
comparision.
Another problem is you are adding " AND " to stLink Critera without
knowing
whether you will be adding any other criteria.
If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND
"
& stExpedited

Normally, if you are building a Where String it would be something
like:

If Not IsNull(Me.FirstCombo) Then
strCriteria = "[SomeField] = '" & Me.FirstCombo & "'"
End If

If Not isNull(Me.SecondCombo) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND"
End If
strCriteria = strCriteria & "[AnotherField] = "Me.SecondCombo"
End If


:

Ok, although I learned alot from the reading, I still cannot get
it to do
what I need.
Let me re-ask my question in it's simpliest form:
One command button.
Three Combo boxes.

Could you please show me the simpliest code, when I click the
command
button, it returns the choices made from the 3 combo boxes.

If I can understand this I will be able to tweek it from there,
for what I
need.

Thank you for the help.


:

The "tick marks" would be correct provided [TR_EXPEDITED] is a
boolean data
type.

I don't know what you mean by "get no return" With a list box,
you have to
use the ItemsSelected collection and handle each selected item
independantly.
Read up on the ItemsSelected property in VBA Help.

:

Ok, I did that and I can select a list of items, but I get no
return of
anything when I click it... Here is my code - please see my
note about 1/2
way down....


Dim stDocName As String
Dim stLinkCriteria As String
Dim Answer As String
Dim stExpedited As String

If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "You must enter a Start & Stop date."
Else

Answer = MsgBox("Expedited Case??", vbQuestion + vbYesNo,
"Question")
If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If

'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" &
Me.InqType & "' AND "
& stExpedited
'''' If I remove the ticks above and put them below (for
status) the job works

If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "'
AND " &
 
Back
Top