-
WSaap2
AskWoody LoungerI am revisiting this issue and have a particular problem. I use the function SelectedClients() described above to create a string of CLIENT IDs. that looks like this.
SelectedClients = “12345W Or 23455C Or 34567T”
I use this statement to open the report.
DoCmd.OpenReport stReportName, acViewPreview, ,[CLIENT]=SelectedClients()
And I always get the following error message.
Microsoft Access can’t find the field ‘I’ referred to in your expression.
I can’t figure out what field is being refered to in the error message. Can you tell from looking at this what the problem might be?
-
WSaap2
AskWoody LoungerFirst of all, thanks for your suggestions.
What is the best way to pass the users selections from this multi-select list box as parameters to the query that is the record source for a report? Below is info on my application.The form is called frmSelectClients
It contains a listbox called lstSelectClients where users select one or more clients.
The form also has a command button called cmdOpenReportSummary used to open a report called rptClientSummaryReport.The query (qrySelectReportData) below is the record source for the report
I have tried the following with no luck.Field: ClientNo, some other fields…
Table: qrySelectByRecoveryPctSvcLine
Total: GroupBy
Sort:
Show: (checked)
Criteria: [forms]![Performance Analysis Client Selection Form]![lstSelectClients] <—WHAT GOES HERE?I have also tried writing a function called SelectedClients() that returns a string of client numbers "Or"d together like this "12345W" Or "23234C" Or "44322S" and tried using this as the query parameter as follows:
Field: ClientNo
…
Criteria: SelectedClient()
It works well if I select one client from the list but returns no data when multiple selections are made.The code for the function follows:
Public Function SelectedClients() As String
'create filter for selected records
Dim ctlSource As Control
Dim strItems As String
Dim intCurrentRow As Integer
Dim intStringLength As Integer
Dim strAster As String 'I tried to use this to pass a wildcard to the query to select all records
Dim strQuote As String 'I used this instead of enclosing quotation marks inside of quotation marksSet ctlSource = Forms![Performance Analysis Client Selection Form]!lstSelectClients
'evaluate number of items on list to make the filter query
'processes more than one item
strQuote = Chr(34)
For intCurrentRow = 0 To ctlSource.ListCount – 1
If ctlSource.Selected(intCurrentRow) Then
strItems = strItems & ctlSource.Column(0, _
intCurrentRow) & strQuote & " Or "& strQuote
End If
Next intCurrentRow'remove the last "Or" from the search string
intStringLength = Len(strItems)
If intStringLength = 0 Then
strAster = Chr(42)
strItems = strAster
Else
strItems = Left(strItems, (intStringLength – 4))
End If
'pass value to function
SelectedClients = strItems'Reset destination control's RowSource property.
Set ctlSource = NothingEnd Function
Or, is it better to use an SQL statement as the report data source and where would I put that SQL Statement? Would it be in the "FilterName" part of the DoCmd.OpenReport line or some other place?
As always, your suggestions are appreciated. -
WSaap2
AskWoody LoungerThanks Charlotte and Mark. I have read posts in this forum related to distributing run time versions to users with other versions of Access on their pc. I have come to find out that of the copies that we need to distribute, some have Access 97 and one Access 2000. I am investigating known issues.
Thanks for your help. -
WSaap2
AskWoody LoungerWe need to distribute databases to customers who have older versions of Access. We believed that MDE files would run on PCs regardless of wheather the user had Access or not. Can you tell me more about the differences in a VB executable and and MDE? We have done some development in Access XP (2002 format) and need to distribute it to a customer who has an older version of Access (97). I made an MDE file thinking that it would run on the user’s pc and it did not. He got the “…unrecognized format…” message. I then thought about making a Visual Basic Executable that connects to the Access db that the user could run. Before I begin the process of making the user interface in Visual Basic, I want to find out if this is a workable solution. Also, we tried to convert the XP back to Access97 and have some debugging issues related to Microsoft Graph.
Any thoughts?
Thanks,
aap2 -
WSaap2
AskWoody LoungerCan you point me to some of the resources that detail the known issues when going from Office 97 to XP or specifically from Access97 to AXP? I have found some articles in MS Knowledge base but am interested in any other resources.
Many thanks,
aap2 -
WSaap2
AskWoody LoungerThank you all, problem solved.
-
WSaap2
AskWoody LoungerThanks for your assistance. Do you mean that in the underlying queries I should add a field like this?
Field: StartDate:[forms]![frmSelectData]![Combo6]
and
Field: EndDate:[forms]![frmSelectData]![Combo8]
Is this what you mean when you said to add them to the query parameters? And are you referring to the underlying queries or the final crosstab or both?Thanks,
aap2 -
WSaap2
AskWoody LoungerI have changed the query Total line to “Where” as you suggested and had the same result.
In the query design grid of the query that does not work, the only reference to date is as follows:
Field: Expr1: “Qtr ” & Format([qryComparisonSearchStep1].[Date],”q”)
Table:
Total: Group By
Crosstab: Column HeadingThis query is based on another query in which my combo boxes are referenced as:
Field: Date
Table: tblTransactionDates
Total: Group By (I changed this to Where, as you suggest and had the same result)
Sort:
Criteria: Between [forms]![frmSelectData]![Combo6] And [forms]![frmSelectData]![combo8] -
WSaap2
AskWoody LoungerPat,
Option Explicit is there and I will create a recordset. Thanks for your assistance. I’ll let you know how it works out.
aap2 -
WSaap2
AskWoody LoungerBelow is a more detailed description of what I am attempting.
The form has a combo box (cboSelectTable) where the user selects an item. The AfterUpdate event of the combo box is what I wish to use. The value of the item selected will determine which table will be searched in the query. The combo box RowSource Type is “Table/Query” and the
SELECT DISTINCTROW tblClientLookUpTablesIndex.TableName, Row Source looks like this
tblClientLookUpTablesIndex.TableDescription FROM tblClientLookUpTablesIndex;
the TableDescription field contains valid table names.cboSelectTable_AfterUpdate()
‘create variable to hold the valid table name
dim mstrLUTable as string
Here is the part I am wondering about. How do I make this assignment so that the variable
“mstrLUTable” holds a valid table name such as “tblLU0301”. And, can you use a variable name in a SQL statement?‘assign the value of the users selection to the variable name
????mstrLUTable = cboSelectTable.value or something like this????Then the varialbe mstrLUTable is filled into this SQL Statement.
SELECT mstrLUTable.Group, mstrLUTable.CBO, mstrLUTable.DIVISION, [LU Program Info].[SERVICE LINE], mstrLUTable.[HOSPITAL ID], mstrLUTable.[HOSPITAL NAME], [LU Program Info].[PLACEMENT NO], [LU Program Info].[PLACEMENT DATE], [LU Program Info].STATE, Stats.[Client No], Stats.[Client Name], Sum(Stats.[MTD # Listed]) AS [SumOfMTD # Listed], Sum(Stats.[MTD $ Listed]) AS [SumOfMTD $ Listed], Sum(Stats.[MTD $ Collected]) AS [SumOfMTD $ Collected], Sum(Stats.[MTD $ Fees]) AS [SumOfMTD $ Fees], Sum(Stats.[YTD $ Listed]) AS [SumOfYTD $ Listed], Sum(Stats.[YTD $ Collected]) AS [SumOfYTD $ Collected], Sum(Stats.[YTD $ Fees]) AS [SumOfYTD $ Fees], Avg(Stats.Age) AS AvgOfAge, Stats.Date
FROM (mstrLUTable LEFT JOIN Stats ON mstrLUTable.[CLIENT NO] = Stats.[Client No]) LEFT JOIN [LU Program Info] ON mstrLUTable.[CLIENT NO] = [LU Program Info].[CLIENT NO]
GROUP BY mstrLUTable.Group, mstrLUTable.CBO, mstrLUTable.DIVISION, [LU Program Info].[SERVICE LINE], mstrLUTable.[HOSPITAL ID], mstrLUTable.[HOSPITAL NAME], [LU Program Info].[PLACEMENT NO], [LU Program Info].[PLACEMENT DATE], [LU Program Info].STATE, Stats.[Client No], Stats.[Client Name], Stats.Date
ORDER BY [LU Program Info].[SERVICE LINE];Once the SQL statement is built, based on the user selection, I want to use that statement in the On Click event of a command button.
Private Sub cmdRunSearch_Click()
On Error GoTo Err_cmdRunSearch_ClickDim stSQLstatement As String
stSQLStatement = the sql statement above
Run the search
End Sub
Many thanks,
aap2 -
WSaap2
AskWoody LoungerThanks for your help. The macro works. I had one other question. Because you declared this as “Public Sub…” does that mean that I can run it from a command button on a form or toolbar? I would like to build this into a command button that cleans up the monthly dataset.
aap2
-
WSaap2
AskWoody LoungerThese are two very good questions. As we pull these data from one system, it is consistent that the last record is not #NA. However, to be safe, I suppose I should put something in place that evaluates the last record to be sure.
Thanks,
aap2 -
WSaap2
AskWoody LoungerThank you for your suggestion. Can you educate me a little here please? Have a look at my comment lines and please tell me if I understand what you are doing here.
Many thanks,
aap2Public Sub CleanUp()
Dim oCell As Range
Dim I As Long, J As Long, lRowMax As Long‘ I think this line tells me the range of cells that will be operated on. A1 to A65536.
‘ Is 65536 an excel default for the maximum number of rows that can be in
‘ a column or did you pick a high number hoping to include the end of data?
‘ does the .End(xlUp) make the program proceed from the bottom up?
lRowMax = Worksheets(“Sheet1”).Range(“A65536”).End(xlUp).Row‘ start at the A1 cell and do some stuff
With Worksheets(“Sheet1”).Range(“A1”)‘ set up an iterative process to systematically go through each cell one at a time and check
‘ for “IsError”. By the way, why the -1 on the lRowMax?
For I = 0 To lRowMax – 1‘ IsError would indicate an empty cell I think.
If IsError(.Offset(I, 0)) Then‘ if an empty cell is found, the IsError is true and this second search happens.
For J = I + 1 To lRowMax – 1
If Not IsError(.Offset(J, 0)) Then‘ if this is not an empty cell, check to see if this is a valid hospital ID.
If Left(.Offset(J, 0), 1) = “1” Then‘ if it is a valid hospital ID, the set the value in the previously found cell .Offset(I,0) to the
‘ value of the valid hospital ID .Offset(J,0). this keeps looping around until lRowMax – 1 is reached.
.Offset(I, 0) = .Offset(J, 0)‘ exit the inner for statement that looped around until lRowMax – 1 was reached
Exit For‘ exit the If statement that looked for an empty cell
End If
End If
Next J
End If
Next I
End With
End Sub -
WSaap2
AskWoody LoungerApril 23, 2002 at 12:45 pm in reply to: Error 3183 Not enought space on temporary disk (Access 97) #583972yes, I believe this was the problem.
thank you.
aap2 -
WSaap2
AskWoody LoungerApril 18, 2002 at 11:54 am in reply to: Error 3183 Not enought space on temporary disk (Access 97) #583140Charlotte,
Thanks. I am not running either MS Repository/Visual Studio or MS Team Manager. I did close some of the other applications that were running in the background and ran the query again and it worked.aap2
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Windows 11 Insider Preview Build 26100.4188 (24H2) released to Release Preview
by
joep517
1 hour, 38 minutes ago -
Microsoft is now putting quantum encryption in Windows builds
by
Alex5723
2 hours, 33 minutes ago -
Auto Time Zone Adjustment
by
wadeer
6 hours, 7 minutes ago -
To download Win 11 Pro 23H2 ISO.
by
Eddieloh
3 hours, 47 minutes ago -
Manage your browsing experience with Edge
by
Mary Branscombe
3 hours ago -
Fewer vulnerabilities, larger updates
by
Susan Bradley
39 minutes ago -
Hobbies — There’s free software for that!
by
Deanna McElveen
2 hours, 58 minutes ago -
Apps included with macOS
by
Will Fastie
3 hours, 48 minutes ago -
Xfinity home internet
by
MrJimPhelps
2 hours, 53 minutes ago -
Convert PowerPoint presentation to Impress
by
RetiredGeek
1 hour, 18 minutes ago -
Debian 12.11 released
by
Alex5723
1 day, 3 hours ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
1 day, 6 hours ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
10 hours, 23 minutes ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
2 hours, 48 minutes ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
1 day, 23 hours ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
1 day, 14 hours ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
2 days, 2 hours ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
1 day, 18 hours ago -
Some advice for managing my wireless internet gateway
by
LHiggins
1 day, 2 hours ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
4 hours, 18 minutes ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
2 days, 12 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
8 minutes ago -
Does windows update component store “self heal”?
by
Mike Cross
1 day, 22 hours ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
3 days, 1 hour ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
1 day, 9 hours ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
22 hours, 34 minutes ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
3 days, 4 hours ago -
Windows 10 Build 19045.5912 (22H2) to Release Preview Channel
by
joep517
3 days, 4 hours ago -
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
2 days, 17 hours ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
3 days, 12 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.