G
Guest
I have a simple multi select box which I am trying to read the values from to
create an IN statement for a query. It seems that my loop produces the data I
was hoping for.
For example if I have A,B,C,D in my list box
the data field strIN comes out looking like 'A','B','C','D' (Code is Below)
What I can not get to work is putting the IN statement in my query correctly
I have tried to read the field strIN. Something to the form of
in ([forms]![FormA]![strIN]) but that did not work !!
I tried to populate a textbox with the values from strIN and tried to read
the textbox values like below. No sucess.
In ([forms]![WorkCenterandNHAKit]![Text17])
below is the code I use to get the values.
Any Suggestons?
Dim counter As Integer
' create the IN string by looping thru the listbox
' where "lstLender" is the name of the list box on the form
For i = 0 To List0.ListCount - 1
counter = (List0.ListCount - 1)
If (i) = counter Then
strIN = strIN & "'" & List0.Column(0, i) & "'"
Else
strIN = strIN & "'" & List0.Column(0, i) & "',"
End If
Next i
' call and run the SQL statement
DoCmd.OpenQuery "testing"
SQL statement
SELECT [Bradley BOM's].CONTRACT, [Bradley BOM's].END_ITEM, [Bradley
BOM's].NHA_PCC, [Bradley BOM's].NHA_SRCPLT, [Bradley BOM's].ITEM_NO, [Bradley
BOM's].PART, [Bradley BOM's].DESCR, [Bradley BOM's].PCC, [Bradley
BOM's].SOURCEPLT, [Bradley BOM's].QTY_PER, [Bradley BOM's].QPV, [Bradley
BOM's].ISSUE_UOM, [Bradley BOM's].PUR_UOM, [Bradley BOM's].ECN_FROM, [Bradley
BOM's].EFF_FROM, [Bradley BOM's].EFF_THRU, [Bradley BOM's].ECN_THRU, [Bradley
BOM's].WORKCENTER, [Bradley BOM's].OPER, [Bradley BOM's].LTOFFSET, [Bradley
BOM's].POSTDEDUCT, [Bradley BOM's].RTG_PRIOR, [Bradley BOM's].PNCATEGORY,
[Bradley BOM's].FROM_ASSY, [Bradley BOM's].EFFFROM_OV, [Bradley
BOM's].EFFTHRU_OV, [Bradley BOM's].THRU_ASSY, [Bradley BOM's].PLANNER,
[Bradley BOM's].NHA
FROM [Bradley BOM's]
WHERE ((([Bradley BOM's].NHA) In ([forms]![WorkCenterandNHAKit]![Text17]))
AND (([Bradley BOM's].TOP_BGEXPN) Is Null) AND ((IIf([forms]![form1]![list72]
Is Null Or [forms]![form1]![list72]=[End_Item],1,0))=1) AND
((IIf([forms]![form1]![list74] Is Null Or
[forms]![form1]![list74]=[Contract],1,0))=1))
ORDER BY [Bradley BOM's].PART, [Bradley BOM's].NHA, [Bradley BOM's].END_ITEM;
In the SQL statement have tried putting
In ([forms]![WorkCenterandNHAKit]![Text17]) and this
([forms]![FormA]![strIN])
neither worked. I am guessing I am trying to read the values wrong into the
IN statement incorrectly.
Thanks in advance
create an IN statement for a query. It seems that my loop produces the data I
was hoping for.
For example if I have A,B,C,D in my list box
the data field strIN comes out looking like 'A','B','C','D' (Code is Below)
What I can not get to work is putting the IN statement in my query correctly
I have tried to read the field strIN. Something to the form of
in ([forms]![FormA]![strIN]) but that did not work !!
I tried to populate a textbox with the values from strIN and tried to read
the textbox values like below. No sucess.
In ([forms]![WorkCenterandNHAKit]![Text17])
below is the code I use to get the values.
Any Suggestons?
Dim counter As Integer
' create the IN string by looping thru the listbox
' where "lstLender" is the name of the list box on the form
For i = 0 To List0.ListCount - 1
counter = (List0.ListCount - 1)
If (i) = counter Then
strIN = strIN & "'" & List0.Column(0, i) & "'"
Else
strIN = strIN & "'" & List0.Column(0, i) & "',"
End If
Next i
' call and run the SQL statement
DoCmd.OpenQuery "testing"
SQL statement
SELECT [Bradley BOM's].CONTRACT, [Bradley BOM's].END_ITEM, [Bradley
BOM's].NHA_PCC, [Bradley BOM's].NHA_SRCPLT, [Bradley BOM's].ITEM_NO, [Bradley
BOM's].PART, [Bradley BOM's].DESCR, [Bradley BOM's].PCC, [Bradley
BOM's].SOURCEPLT, [Bradley BOM's].QTY_PER, [Bradley BOM's].QPV, [Bradley
BOM's].ISSUE_UOM, [Bradley BOM's].PUR_UOM, [Bradley BOM's].ECN_FROM, [Bradley
BOM's].EFF_FROM, [Bradley BOM's].EFF_THRU, [Bradley BOM's].ECN_THRU, [Bradley
BOM's].WORKCENTER, [Bradley BOM's].OPER, [Bradley BOM's].LTOFFSET, [Bradley
BOM's].POSTDEDUCT, [Bradley BOM's].RTG_PRIOR, [Bradley BOM's].PNCATEGORY,
[Bradley BOM's].FROM_ASSY, [Bradley BOM's].EFFFROM_OV, [Bradley
BOM's].EFFTHRU_OV, [Bradley BOM's].THRU_ASSY, [Bradley BOM's].PLANNER,
[Bradley BOM's].NHA
FROM [Bradley BOM's]
WHERE ((([Bradley BOM's].NHA) In ([forms]![WorkCenterandNHAKit]![Text17]))
AND (([Bradley BOM's].TOP_BGEXPN) Is Null) AND ((IIf([forms]![form1]![list72]
Is Null Or [forms]![form1]![list72]=[End_Item],1,0))=1) AND
((IIf([forms]![form1]![list74] Is Null Or
[forms]![form1]![list74]=[Contract],1,0))=1))
ORDER BY [Bradley BOM's].PART, [Bradley BOM's].NHA, [Bradley BOM's].END_ITEM;
In the SQL statement have tried putting
In ([forms]![WorkCenterandNHAKit]![Text17]) and this
([forms]![FormA]![strIN])
neither worked. I am guessing I am trying to read the values wrong into the
IN statement incorrectly.
Thanks in advance