RE: combo box...then multi select list box
- From: Klatuu <Klatuu@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 6 Dec 2005 13:30:03 -0800
I don't see anything obvious. I would put a breakpoint just before the line
qdf.SQL = strSQL
I am pretty sure there is a problem with the SQL string based on the error
you are getting and where it is happening.
Also, I have included a function I use to build my where conditions
Private Function BuildWhereCondition(strControl As String) As String
'Set up the WhereCondition Argument for the reports
Dim varItem As Variant
Dim strWhere As String
Dim ctl As Control
Set ctl = Me.Controls(strControl)
Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhere = ""
Case 1 'Only One Selected
strWhere = "= '" & _
ctl.ItemData(ctl.ItemsSelected(0)) & "'"
Case Else 'Multiple Selection
strWhere = " IN ("
With ctl
For Each varItem In .ItemsSelected
strWhere = strWhere & "'" & .ItemData(varItem) & "', "
Next varItem
End With
strWhere = Left(strWhere, Len(strWhere) - 2) & ")"
End Select
BuildWhereCondition = strWhere
End Function
"Kevin" wrote:
> I have never stepped through VB code, but found how to do so in the Help
> Topics. While I'm working on that, I have another question...
>
> I set up this code in the OnClick Event. My form is set up so that you make
> the selections in each box, then click a command button for various available
> reports. When I had the 2 combo boxes, the second box had no event code, so
> it didn't do anything until you clicked the appropriate command button. It
> seems to me, logically, that having the code in the OnClick event would fire
> something prematurely. Am I wrong in thinking that?
>
> To further add to my dilemma/question...The SQL for qryDialog was previously:
> SELECT Bid.ProjectName, *
> FROM Bid
> WHERE (((Bid.ProjectName)=[Forms]![frmEstimatSelector1]![cboProjectName])
> AND ((Bid.BidNumber)=[Forms]![frmEstimatSelector1]![lstBidNumber]));
>
>
> Now, after I click in the control lstBidNumber and get the error, it
> automatically changes the SQL to:
> SELECT *
> FROM Bid
> WHERE (((Bid.BidNumber) In ('1')));
>
> I am probably in over my head with this, but have received great help with
> this forum in the past, and have learned a great deal. If any of the above
> info helps clue you in to a possible problem, I certainly appreciate any help
> in the matter!
> Thanks again!
>
> "Klatuu" wrote:
>
> > Have you stepped through in debug mode and looked at the SQL in qryDialog?
> > It may be that there is a syntax problem.
>
.
- Follow-Ups:
- RE: combo box...then multi select list box
- From: Kevin
- RE: combo box...then multi select list box
- Prev by Date: Re: multi entry on one form
- Next by Date: RE: Make text box control source change based on a check box selection
- Previous by thread: Re: multi entry on one form
- Next by thread: RE: combo box...then multi select list box
- Index(es):