Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Previewing Forms for Certain data

Status
Not open for further replies.

bebbo

Programmer
Dec 5, 2000
621
GB
I've got code shown below which shows a stkhistory report. This report either shows all stock items or stock items stock items in a certain group. These groups are pick by the operator selecting a group from a listbox, no problem. Problem I have is if the operator wants to show 2 or 3 groups but not all of them.

I can easily pick up chosen groups but how would I make my report show these chosen groups. I know I could use stkrecord = 1 or stkrecord = 2 etc but the operator could pick two groups 3, 4 or indeed any amount of groups.

Thanks


IF ChosenDept = 0
REPORT FORM StkHistory ;
PREVIEW FOR STKRECORD.DEPT != 9999
ELSE
REPORT FORM StkHistory ;
PREVIEW FOR STKRECORD.DEPT = ChosenDept
ENDIF
 
Hi Bebbo,

Try using INLIST eg

... FOR INLIST (StkRecord.Dept,'01','03','06')
 
You would need to iterate through the list box for each item that is selected and either build a string of them for macro expansion or build a table of them and use a SELECT statement to JOIN that table to the one you want to report from.

Some sample code for the first selection would be:
Code:
cList=""
with thisform.lstChoice
	for nRec=1 to .listcount
		if .selected(nRec)
			cList=cList+","+.listitem(i)
		endif
	next
endwith
IF !EMPTY(cList)
	REPORT FORM StkHistory PREVIEW ;
	  FOR INLIST(STKRECORD.DEPT &cList)
ENDIF
This is assuming that the listbox contains the department numbers as the column value. You should be able to modify it to work if that's not the case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top