-
WSDrew
AskWoody LoungerEvery so often I get snagged by this one myself. ADO doesn’t use the asterisk (*) for a wildcard. ADO uses the percent symbol %. So replace the * with a percent symbol, and you should be good to go.
Odd, isn’t it? You can paste the SQL directly into a query, and it works, but ADO does not see the * as a wildcard.
Hope this helps!
-
WSDrew
AskWoody LoungerEvery so often I get snagged by this one myself. ADO doesn’t use the asterisk (*) for a wildcard. ADO uses the percent symbol %. So replace the * with a percent symbol, and you should be good to go.
Odd, isn’t it? You can paste the SQL directly into a query, and it works, but ADO does not see the * as a wildcard.
Hope this helps!
-
WSDrew
AskWoody LoungerOh, I had always thought it was SQL Server, because Jet doesn’t mind getting an actual date variable. So Jet just ‘comprimises’ I guess. Learn something knew everyday.
-
WSDrew
AskWoody LoungerOh, I had always thought it was SQL Server, because Jet doesn’t mind getting an actual date variable. So Jet just ‘comprimises’ I guess. Learn something knew everyday.
-
WSDrew
AskWoody LoungerNot a waste of time. Sometimes we all need a second pair of eyes on something, that’s why the lounge is here!
As for the date formatting, if you stick with Access, you can’t go wrong with #” & dteSomDateVariable & “# because the date variable is a constant format (double variable, whole numbers for days, decimal for time), which is Universal in Access. If you want it to work in SQL server, then I believe SQL Server wants MM/DD/YYYY.
-
WSDrew
AskWoody LoungerNot a waste of time. Sometimes we all need a second pair of eyes on something, that’s why the lounge is here!
As for the date formatting, if you stick with Access, you can’t go wrong with #” & dteSomDateVariable & “# because the date variable is a constant format (double variable, whole numbers for days, decimal for time), which is Universal in Access. If you want it to work in SQL server, then I believe SQL Server wants MM/DD/YYYY.
-
WSDrew
AskWoody LoungerAha. adCmdTableDirect has always worked for me for naming a table in the Open method. Honestly don’t think I tried adCmdTable. Quite frankly, for the past year or two, I simply leave the default, because I’m using SQL statements, and if I am just adding a record, I don’t even use a recordset, I just use INSERT INTO statements….though, if I had a ‘massive’ data dump, I would go back to recordsets.
Either way, it’ll be interesting to find out if the Options argument is the cause of the actual problem.
-
WSDrew
AskWoody LoungerAha. adCmdTableDirect has always worked for me for naming a table in the Open method. Honestly don’t think I tried adCmdTable. Quite frankly, for the past year or two, I simply leave the default, because I’m using SQL statements, and if I am just adding a record, I don’t even use a recordset, I just use INSERT INTO statements….though, if I had a ‘massive’ data dump, I would go back to recordsets.
Either way, it’ll be interesting to find out if the Options argument is the cause of the actual problem.
-
WSDrew
AskWoody LoungerThat’s what I thought, I always leave it blank, which defaults to -1, which I am not sure what that is. But I always thought adCmdTable, and adCmdTableDirect was used when you refer to a table, and not to a SQL string. When I saw this post, I checked the help file, and quite frankly felt more confused about the issue. I have opened tables directly with ADO (if I am just adding a record), and put “tblSomething” where a SQL statement would go, and I have problems if I don’t use adCmdTableDirect (though I don’t think I tried adCmdTable).
-
WSDrew
AskWoody LoungerThat’s what I thought, I always leave it blank, which defaults to -1, which I am not sure what that is. But I always thought adCmdTable, and adCmdTableDirect was used when you refer to a table, and not to a SQL string. When I saw this post, I checked the help file, and quite frankly felt more confused about the issue. I have opened tables directly with ADO (if I am just adding a record), and put “tblSomething” where a SQL statement would go, and I have problems if I don’t use adCmdTableDirect (though I don’t think I tried adCmdTable).
-
WSDrew
AskWoody LoungerHmm, you’re right, I guess I deal with Callback functions too much, because with a callback function, it DOES size the slider based on the number of items. Try populating the combo with a callback function.
-
WSDrew
AskWoody LoungerHmm, you’re right, I guess I deal with Callback functions too much, because with a callback function, it DOES size the slider based on the number of items. Try populating the combo with a callback function.
-
WSDrew
AskWoody LoungerThat’s not entirely true. A combobox has to get the initial ‘count’ when it loads, so when the list is dropped down, the data my not be ‘all there’, but the slider will be the appropriate size. You may want to look into using a callback function, if you suspect you are ‘losing’ the connection somehow.
-
WSDrew
AskWoody LoungerThat’s not entirely true. A combobox has to get the initial ‘count’ when it loads, so when the list is dropped down, the data my not be ‘all there’, but the slider will be the appropriate size. You may want to look into using a callback function, if you suspect you are ‘losing’ the connection somehow.
-
WSDrew
AskWoody LoungerHere’s the SQL for a single query solution:
SELECT ProdID, yearno, weekno, T1.sold, (SELECT TOP 1 itemsperbox FROM itemsize WHERE (itemsize.yearno=T1.yearno AND itemsize.weekno<=T1.weekno) OR itemsize.yearno<T1.yearno ORDER BY yearno DESC, weekno DESC) AS ItemsPerBox, (SELECT TOP 1 itemsperbox*T1.sold AS total FROM itemsize WHERE (itemsize.yearno=T1.yearno AND itemsize.weekno<=T1.weekno) OR itemsize.yearno<T1.yearno ORDER BY yearno DESC, weekno DESC) AS total
FROM sold AS T1
ORDER BY ProdID, yearno, weekno;I used itemsize and sold as the table names, per your post, but I would recommend changing them to tblItemSize and tblSold. (the sold table has a sold field…which can lead to some confusion.
Note, the query results will have 'nulls' instead of zeros, if there is no itemsperbox value 'yet'. If you must have zeros, then use this (it will just take longer…)
SELECT ProdID, yearno, weekno, T1.sold, IIF(IsNull((SELECT TOP 1 itemsperbox FROM itemsize WHERE (itemsize.yearno=T1.yearno AND itemsize.weekno<=T1.weekno) OR itemsize.yearno<T1.yearno ORDER BY yearno DESC, weekno DESC)),0,(SELECT TOP 1 itemsperbox FROM itemsize WHERE (itemsize.yearno=T1.yearno AND itemsize.weekno<=T1.weekno) OR itemsize.yearno<T1.yearno ORDER BY yearno DESC, weekno DESC)) AS ItemsPerBox, IIF(IsNull((SELECT TOP 1 itemsperbox*T1.sold AS total FROM itemsize WHERE (itemsize.yearno=T1.yearno AND itemsize.weekno<=T1.weekno) OR itemsize.yearno<T1.yearno ORDER BY yearno DESC, weekno DESC)),0,(SELECT TOP 1 itemsperbox*T1.sold AS total FROM itemsize WHERE (itemsize.yearno=T1.yearno AND itemsize.weekno<=T1.weekno) OR itemsize.yearno<T1.yearno ORDER BY yearno DESC, weekno DESC)) AS total
FROM sold AS T1
ORDER BY ProdID, yearno, weekno;You can get zero's with the first query (which would be faster, by putting records in the itemsize table like a,1,1,0, but that may disrupt other systems in your database)
Have fun….
![]() |
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
-
I hate that AI is on every computer we have! (Awaiting moderation)
by
1bumthumb
1 hour, 40 minutes ago -
Windows Update says that “some settings are managed b your organization”
by
Ed Willers
1 hour, 44 minutes ago -
Use of Gmail rejected.
by
CBFPD-Chief115
8 hours, 2 minutes ago -
WuMgr operational questions
by
Tex265
8 hours, 46 minutes ago -
Beijing’s unprecedented half-marathon: Humans vs. humanoids!
by
Alex5723
13 hours, 49 minutes ago -
New Phishing Campaign Targeted at Mac Users
by
Alex5723
3 hours, 19 minutes ago -
Backing up Google Calendar
by
CWBillow
20 hours, 17 minutes ago -
Windows 11 Insider Preview build 27818 released to Canary
by
joep517
1 day, 8 hours ago -
File Naming Conventions (including Folders)
by
Magic66
7 hours, 39 minutes ago -
Windows 11 Insider Preview Build 26100.3613 (24H2) released to Release Preview
by
joep517
1 day, 16 hours ago -
Microsoft sends emails to Windows 10 users about EOS
by
Alex5723
1 day, 2 hours ago -
Outlook 2024 importing Calendar and Contacts – FAILURE
by
Kathy Stevens
9 hours, 9 minutes ago -
Adding Microsoft Account.
by
DaveBRenn
1 day, 17 hours ago -
Windows 11 Insider Preview build 26120.3576 released to DEV and BETA
by
joep517
2 days, 17 hours ago -
Windows 11 Insider Preview Build 22635.5090 (23H2) released to BETA
by
joep517
2 days, 17 hours ago -
Windows 11 won’t boot
by
goducks25
9 hours, 57 minutes ago -
Choosing virtual machine product for Windows on Mac
by
peterb
2 days, 7 hours ago -
Rest in Peace
by
Roy Lasris
3 days, 11 hours ago -
CISA : Install Windows March 2025 Updates until April 1 or shut down PC.
by
Alex5723
9 hours, 32 minutes ago -
Google proposes users with incompatible Win 11 PCs to migrate to ChromeOS Flex
by
Alex5723
3 days, 12 hours ago -
Drivers for Epson Perfection V600 Photo – scanner
by
Bookman
3 hours, 50 minutes ago -
Long Time Member
by
jackpet
3 days, 15 hours ago -
Woody Leonhard (1951–2025)
by
Will Fastie
10 hours, 40 minutes ago -
What I learned from Woody Leonhard
by
B. Livingston
3 days, 8 hours ago -
Windows Settings today
by
Simon Bisson
3 days, 23 hours ago -
Mail Merge magic in Microsoft Word
by
Peter Deegan
21 hours, 18 minutes ago -
Businesses in the crosshairs
by
Susan Bradley
2 days, 12 hours ago -
Double-row taskbar?
by
CWBillow
1 day, 4 hours ago -
Upgrading non-supported HW to Win 11
by
RetiredGeek
1 day, 14 hours ago -
Audio locks up after 15 minutes
by
WSArthurR
1 day, 13 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.