-
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
-
Microsoft is now putting quantum encryption in Windows builds
by
Alex5723
1 minute ago -
Auto Time Zone Adjustment
by
wadeer
3 hours, 35 minutes ago -
To download Win 11 Pro 23H2 ISO.
by
Eddieloh
1 hour, 15 minutes ago -
Manage your browsing experience with Edge
by
Mary Branscombe
28 minutes ago -
Fewer vulnerabilities, larger updates
by
Susan Bradley
28 minutes ago -
Hobbies — There’s free software for that!
by
Deanna McElveen
26 minutes ago -
Apps included with macOS
by
Will Fastie
1 hour, 16 minutes ago -
Xfinity home internet
by
MrJimPhelps
21 minutes ago -
Convert PowerPoint presentation to Impress
by
RetiredGeek
2 hours, 30 minutes ago -
Debian 12.11 released
by
Alex5723
1 day ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
1 day, 4 hours ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
7 hours, 51 minutes ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
16 minutes ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
1 day, 21 hours ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
1 day, 11 hours ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
2 days ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
1 day, 16 hours ago -
Some advice for managing my wireless internet gateway
by
LHiggins
23 hours, 49 minutes ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
1 hour, 46 minutes ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
2 days, 9 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
2 days, 5 hours ago -
Does windows update component store “self heal”?
by
Mike Cross
1 day, 19 hours ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
2 days, 23 hours ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
1 day, 7 hours ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
20 hours, 2 minutes ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
3 days, 2 hours ago -
Windows 10 Build 19045.5912 (22H2) to Release Preview Channel
by
joep517
3 days, 2 hours ago -
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
2 days, 14 hours ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
3 days, 10 hours ago -
0Patch, where to begin
by
cassel23
3 days, 4 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.