Re: combo choose 1 or many
- From: Dan @BCBS <DanBCBS@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 30 May 2006 12:56:02 -0700
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" wrote:
Caught my typo, thanks, actually, it is text and should be:.
strCriteria = strCriteria & "[TR_DECISION] = '" & Me.DecCode & "'"
"Douglas J Steele" wrote:
The last statement needs to be:
strCriteria = strCriteria & "[TR_DECISION] = Me.DecCode"
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Dan @BCBS" <DanBCBS@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:49CB9213-AE58-4253-9937-4C6A14E5E2F0@xxxxxxxxxxxxxxxx
1. I added the space after AND.get
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
the correct decision:this
If Not (IsNull(Me.cmbstatus)) Then
stCriteria = "[TR_STATUS]= '" & Me.cmbstatus & "'
The problem seems to be in the second IF, the results completly ecnore
combo box and the return is all of them.copied;
If Not (IsNull(Me.DecCode)) Then
If Len(strCriteria) > 0 Then
strCriteria = strCriteria & " AND "
strCriteria = "[TR_DECISION] = Me.DecCode"
HELP
"Klatuu" wrote:
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
thehowever, your open report may still be using stLinkCriteria. Be sure
arevariable name you are using to build the Where string is the same you
return ofusing in the OpenReport.
"Dan @BCBS" wrote:
You have me going in the right direction, but I am getting a data
are addingall 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" wrote:
I' having a little trouble understanding your code. I notice you
reallystexpedited to more than one field. Can you tell me how stexpedited
knowingworks. The syntax below has stExpedited after the word AND with no
comparision.
Another problem is you are adding " AND " to stLink Critera without
"whether you will be adding any other criteria.
If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" & Me.InqType & "' AND
like:& stExpedited
Normally, if you are building a Where String it would be something
it to do
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" wrote:
Ok, although I learned alot from the reading, I still cannot get
commandwhat 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
for what Ibutton, it returns the choices made from the 3 combo boxes.
If I can understand this I will be able to tweek it from there,
boolean dataneed.
Thank you for the help.
"Klatuu" wrote:
The "tick marks" would be correct provided [TR_EXPEDITED] is a
you have totype.
I don't know what you mean by "get no return" With a list box,
independantly.use the ItemsSelected collection and handle each selected item
return ofRead up on the ItemsSelected property in VBA Help.
"Dan @BCBS" wrote:
Ok, I did that and I can select a list of items, but I get no
note about 1/2anything when I click it... Here is my code - please see my
"Question")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,
Me.InqType & "' AND "If Answer = vbYes Then
stExpedited = "[TR_EXPEDITED]=True"
Else
stExpedited = "[TR_EXPEDITED]=False"
End If
'If Not (IsNull(Me.InqType)) Then
' stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" &
status) the job works& stExpedited
'''' If I remove the ticks above and put them below (for
AND " &
If Not (IsNull(Me.status)) Then
stLinkCriteria = "[TR_STATUS]=" & "'" & Me.status & "'
"' AND " &stExpedited
If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" & Me.DecCode &
For thisstExpedited
End If
stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
"Klatuu" wrote:
You cannot choose more than one selection from a combo box.
property set to eithercapability, you need a List Box with the Multi Select
ItemsSelectedSimple or Extended. Once you have made the selections, the
selections.collection of the ListBox will contain a list of the
choose one from the
"Dan @BCBS" wrote:
Sorry, this is what I have, but it only allows me to
Me.InqType & "' AND " &combo box...
If Not (IsNull(Me.InqType)) Then
stLinkCriteria = "[TR_INQUIRYTYPE]=" & "'" &
Me.DecCode & "' AND " &stExpedited
If Not (IsNull(Me.DecCode)) Then
stLinkCriteria = "[TR_DECISION]=" & "'" &
stLinkCriteriastExpedited
End If
stDocName = "r_GroupBasic"
DoCmd.OpenReport stDocName, acPreview, ,
more confused, when I
"Dan @BCBS" wrote:
Could you please help me get started, I'm just getting
then click theread.
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
command for the results of the query.
Thank you
- Follow-Ups:
- Re: combo choose 1 or many
- From: Klatuu
- Re: combo choose 1 or many
- References:
- RE: combo choose 1 or many
- From: Dan @BCBS
- RE: combo choose 1 or many
- From: Klatuu
- RE: combo choose 1 or many
- From: Dan @BCBS
- RE: combo choose 1 or many
- From: Klatuu
- RE: combo choose 1 or many
- From: Dan @BCBS
- RE: combo choose 1 or many
- From: Klatuu
- RE: combo choose 1 or many
- From: Dan @BCBS
- Re: combo choose 1 or many
- From: Douglas J Steele
- Re: combo choose 1 or many
- From: Klatuu
- RE: combo choose 1 or many
- Prev by Date: IIf Condition
- Next by Date: Re: combo choose 1 or many
- Previous by thread: Re: combo choose 1 or many
- Next by thread: Re: combo choose 1 or many
- Index(es):
Relevant Pages
|