-
WSaap2
AskWoody LoungerYou have to invest a bit of time to learn how to use it, but then it works very well indeed.
Thanks all. We’re temporarily using the “CheckYes” option. This works for now until we get either SQL Server Reporting Services figured out or SQL Database Mail scripted.
—aap2—
-
WSaap2
AskWoody LoungerOK, I see that the problem is simple. I spelled the word “THURSDAY” incorrectly. The query works now!
I suppose this is one of those ID10T errors.
Best regards,
-
WSaap2
AskWoody LoungerFebruary 19, 2009 at 3:44 pm in reply to: Linking SQL Server Tables with ODBC (Access 2003) #1147986Yes. I do have a startup form. I’ll move the call statement to the OnOpen event and see what happens.
By the way, I will hide the table and hide the database window and disable special keys to prevent SQL credentials from being exposed. If anyone is aware of a more secure way to do this, I would l like to find out. But that is for another post.
Thanks.
-
WSaap2
AskWoody LoungerAs always, worked like a charm!
Thank you. -
WSaap2
AskWoody LoungerThank you. I must have missed that. In order to restrict users to one selection when option 2 (Weekly) is chosen, I suppose I must make a different list box visible where multi-select is set to 0.
Thanks again! -
WSaap2
AskWoody LoungerHans,
I did two things.
1. I defined a variable called strSQL in the beginning of the procedure like this:
Dim strSQL as stringstrSQL = “SELECT DISTINCT CM_CLIENT.CHAIN, ”
strSQL = strSQL & “CM_Service_Line_Master.ServiceLineDescription, ”
strSQL = strSQL & “CM_CLIENT.LINE_OF_BUSINES FROM CM_DEBTOR ”
strSQL = strSQL & “INNER JOIN CM_CLIENT ON CM_CLIENT.CLIENT_NUM = CM_DEBTOR.Client ”
strSQL = strSQL & “INNER JOIN CM_Service_Line_Master ON CM_CLIENT.LINE_OF_BUSINES = CM_Service_Line_Master.ServiceLineID ”
strSQL = strSQL & “Where CM_CLIENT.CHAIN = ‘” & strChain & “‘”2. I took the ” =Array(“…”) ” part out of the .CommandText = Array(“…”)
and replaced it with .CommandText = strSQL and it works.It seems that if you build your query by recording a macro, it inserts the .CommandText = Array(“…”) for some reason.
As always, thanks for your guidance.
-
WSaap2
AskWoody LoungerI’m attempting to populate Sheet1 with a list of data from our SQL Server 2005 database. The following query works well if I don’t add the WHERE clause.
I keep getting a type mismatch error with the .CommandText = Array line when I add the WHERE clause.Some other useful info regarding my question:
1. I pass in a code called strChain
2. Each chain has 1 or more service lines
3. I want to return only the service lines for the chain code that is passed in.
4. If you know of a better way to pass in an SQL string to the database, I’m happy to give it a try!Sub ChainSvcLines(ByVal strChain As String)
On Error GoTo Error_HandlerWith ActiveSheet.QueryTables.Add(Connection:= _
“ODBC;DRIVER=SQL Server;SERVER=999.99.99.9;UID=user123;PWD=*********;APP=Microsoft Office 2003;WSID=XXX-XXXXXX” _
, Destination:=Range(“I2”))
.CommandText = Array(“SELECT DISTINCT CM_CLIENT.CHAIN, ” & _
“CM_Service_Line_Master.ServiceLineDescription , CM_CLIENT.LINE_OF_BUSINES ” & _
“FROM CM_DEBTOR INNER JOIN CM_CLIENT ON CM_CLIENT.CLIENT_NUM = CM_DEBTOR.Client ” & _
“INNER JOIN CM_Service_Line_Master ON CM_CLIENT.LINE_OF_BUSINES = CM_Service_Line_Master.ServiceLineID ” & _
“WHERE CM_CLIENT.CHAIN = ‘ ” strChain & ” ‘ “)
.Name = “qryChainLOB”
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
Error_Handler:
MsgBox Err.Number & ” ” & Err.DescriptionEnd Sub
As always, any suggestions would be most helpful.
Thanks, -
WSaap2
AskWoody LoungerMy mistake. It should say strChain which is the value passed in. Sorry about that.
-
WSaap2
AskWoody LoungerI did what you suggested (Exported, removed, imported) and still had the same issue. I even started with a new workbook and imported all the modules and form. However, because I had to shutdown overnight, when I re-opened the application, the strange behavior was gone. I don’t know why it happened but I am investigating Hans V’s link as well as looking into the code cleaner you mentioned.
Thanks, -
WSaap2
AskWoody LoungerThanks again Hans. Works just fine.
FYI, the GetRealLastCell procedure is a handy piece of code that we use very frequently in most of our Excel apps.
I don’t know who gets credit for writing it. I may have found it here in this forum.
‘=============================================================
Option Explicit
Public RealLastRow As Long
Public RealLastColumn As LongPublic Sub GetRealLastCell()
Range(“A1”).Select
On Error Resume Next
RealLastRow = Cells.Find(“*”, Range(“A1”), xlFormulas, , xlByRows, xlPrevious).Row
RealLastColumn = Cells.Find(“*”, Range(“A1”), xlFormulas, , xlByColumns, xlPrevious).Column
Cells(RealLastRow, RealLastColumn).Select
End Sub
‘============================================================= -
WSaap2
AskWoody LoungerHans,
I did as you suggested on the user PC and compiled the MDB without any problem.
I was able to make what appears to be a working executable (still testing on other user desktops).
I didn’t see any MISSING references but I did notice that on my PC I have references to:
Microsoft Access 11 object library and Microsoft Office 11 object library
whereas our users show:
Microsoft Access 10 object library and Microsoft Office 10 object libraryOnce again, you have been very helpful!
Thanks,
aap2 -
WSaap2
AskWoody LoungerThanks Hans. Can you tell me why this change worked where the original line of code did not?
-
WSaap2
AskWoody LoungerThanks Hans. The TimeValue function will help with the calculation portion but I still need a way to determine “AM” or “PM”. It appears that the TimeValue function assumes “AM” if the argument is not stamped. I have decided that looping through a recordset of each persons Finished_Time and counting the changes in the Hours will help determine if the span of time crosses noon. If that is the case, I know that SessionStart is AM and Finished_Time is PM.
I put in this block of code….
=======================================
Sub TestTime()
‘some other dim statements here…Dim intFirstFinish As Integer
Dim intNextFinish As Integer
Dim intLastFinish As Integer‘ I open a recordset here called rsdata…
‘ I get the count of records in rsdata. intRecordCount‘ val function captures the numbers in the hours portion of the string.
intFirstFinish = Val(rsData.Fields(“Finished_Time”))
intLastFinish = Val(rsData.Fields(“Finished_Time”))For i = 1 To intRecCount
intNextFinish = Val(rsData.Fields(“Finished_Time”).Value)
If intNextFinish intFirstFinish Then
‘calculation of the number of times the hour changes.intHrs = intHrs + 1
intFirstFinish = intNextFinish
End If
rsData.MoveNext
Next iSelect Case intHrs
‘ I think I need some logic here that says if the number of hour changes is > some number then
‘ SessionStart is AM and Finished_Time is PM
‘ Else Both are AM or Both are PM — I don’t have this logic figured out yet.End Select
-
WSaap2
AskWoody LoungerThanks Hans. This is exactly what I had in mind.
-
WSaap2
AskWoody LoungerWendell,
Thanks for the tip. I did try the upsizing wizard and SQL put [square brackets] around the field names instead of _underscores_ . I don’t recall any options in the upsizing wizard that would allow you to customize how Access handles field names. I was told however, that using DTS and pulling data into SQL instead of pushing data out of access might be an option. If anyone has any knowledge on this, let me know.Thanks,
![]() |
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
-
How to enable Extended Security Maintenance on Ubuntu 20.04 LTS before it dies
by
Alex5723
3 minutes ago -
Windows 11 Insider Preview build 26200.5562 released to DEV
by
joep517
4 hours, 1 minute ago -
Windows 11 Insider Preview build 26120.3872 (24H2) released to BETA
by
joep517
4 hours, 3 minutes ago -
Unable to eject external hard drives
by
Robertos42
3 hours, 39 minutes ago -
Saying goodbye to not-so-great technology
by
Susan Bradley
7 hours, 13 minutes ago -
Tech I don’t miss, and some I do
by
Will Fastie
4 hours, 8 minutes ago -
Synology limits hard drives
by
Susan Bradley
1 day, 8 hours ago -
Links from Microsoft 365 and from WhatsApp not working
by
rog7
10 hours, 40 minutes ago -
WhatsApp Security Advisories CVE-2025-30401
by
Alex5723
1 day, 14 hours ago -
Upgrade Sequence
by
doneager
1 day, 7 hours ago -
Chrome extensions with 6 million installs have hidden tracking code
by
Nibbled To Death By Ducks
1 day, 7 hours ago -
Uninstall “New Outlook” before installing 2024 Home & Business?
by
Tex265
6 hours, 28 minutes ago -
The incredible shrinking desktop icons
by
Thumper
2 days, 11 hours ago -
Windows 11 Insider Preview Build 22635.520 (23H2) released to BETA
by
joep517
2 days, 12 hours ago -
Connecting hard drive on USB 3.2 freezes File Explorer & Disk Management
by
WSJMGatehouse
1 day, 8 hours ago -
Shellbag Analyser & Cleaner Update
by
Microfix
22 hours, 2 minutes ago -
CISA warns of increased breach risks following Oracle Cloud leak
by
Nibbled To Death By Ducks
2 days, 22 hours ago -
Outlook 2024 two sent from email addresses
by
Kathy Stevens
2 days, 2 hours ago -
Speeding up 11’s search
by
Susan Bradley
10 hours, 30 minutes ago -
HP Pavilion Will Not Wake Up After Being Idle for Longer Period
by
WSwalterwood44
22 hours, 27 minutes ago -
Make a Windows 11 Local Account Passwordless
by
Drcard:))
3 days, 12 hours ago -
Ubuntu 25.04 (Plucky Puffin)
by
Alex5723
3 days, 19 hours ago -
24H2 fixed??
by
CWBillow
2 days, 12 hours ago -
Uninstalr Updates
by
jv16
4 days ago -
Apple zero days for April
by
Susan Bradley
3 days, 5 hours ago -
CVE program gets last-minute funding from CISA – and maybe a new home
by
Nibbled To Death By Ducks
2 days, 22 hours ago -
Whistleblower describes DOGE IT dept rumpus at America’s labor watchdog
by
Nibbled To Death By Ducks
4 days, 23 hours ago -
Seeing BSOD’s on 24H2?
by
Susan Bradley
4 days, 6 hours ago -
TUT For Private Llama LLM, Local Installation and Isolated from the Internet.
by
bbearren
4 days, 14 hours ago -
Upgrade from Windows 10 to 11
by
Holdsworth8
5 days, 8 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.