Urgent: Generating Reports with Multiple Inputs

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

Guest

I have a report to be generated where the user enters multiple serial

numbers of clients. For example, I have 100 clients now the user wishes to

print the data of say 3rd, 5th, 10th, 28th, 100th client then the report

should be able to generate only the details the above mentioned clients.

He should be able to enter the serial number of as many clients as he wants
or a

limited number of clients.

Thanks.
 
There is really no such thing as 1st, 2nd, or 3rd records in Access. I
understand your question to mean selecting multiple clients that might not
have anything in common. I use multi-select list boxes to do this. I have a
single function that I call to build a "where" statement to use in the
OpenReport line of code. The code to create the syntax is listed below:

Function LBOWhere(pctlListBox As ListBox, pstrFieldName As String, pstrDelim
As String) As String
'============================================================
' Purpose: Return a where clause like " [State] IN ('MN', 'WI', 'SD')
"
' Programmer: Duane Hookom
' Called From: Multiple
' Date: 2/21/2003
' Parameters: listbox control object, field name for where clause
'============================================================
On Error GoTo LBOWhere_Err
Dim strErrMsg As String 'For Error Handling

Dim strWhere As String
Dim varItem As Variant
'make sure items are selected
If pctlListBox.ItemsSelected.Count > 0 Then
strWhere = " " & pstrFieldName & " IN ("
For Each varItem In pctlListBox.ItemsSelected
strWhere = strWhere & pstrDelim & pctlListBox.ItemData(varItem)
& pstrDelim & ", "
Next
strWhere = " AND " & Left(strWhere, Len(strWhere) - 2) & ") "
Else
LBOWhere = ""
End If
LBOWhere = strWhere

LBOWhere_Exit:
On Error Resume Next
Exit Function

LBOWhere_Err:
Select Case Err
Case Else
strErrMsg = strErrMsg & "Error #: " & Format$(Err.Number) &
vbCrLf
strErrMsg = strErrMsg & "Error Description: " & Err.Description
MsgBox strErrMsg, vbInformation, "LBOWhere"
Resume LBOWhere_Exit
End Select
End Function
 
Back
Top