-
WSsteve_skelton13
AskWoody LoungerPleased to be of service!
here’s the situations: on a windows form, you have several combo boxes with standard items (such as Yes, No, N/A). In Access, you can create a lookup table and bind the control itself to some other table. In .NET there is no corresponding RowSource setting. If you use the same data source for a series of combo boxes to the same lookup table, the application will also ‘bind’ every single comb box, meaning selecting Yes in one selects Yes in all the others.
I believe this happens because .NET has a setting called ‘CurrencyManager’ that handles data binding for any instance that where it is declared, even if the data source is on multiple controls.
So, instead of just setting the controls to the same data source, you need to do something like this in the code-behind:
Use the same datasource but prevent the controls from interacting:
Me.ComboBox1.DataSource = New DataView(_MyDatabase_1DataSet.MyDataTable) <– note the keyword 'New'
Me.ComboBox2.DataSource = New DataView(_MyDatabase_1DataSet.MyDataTable) <– note the keyword 'New'Automatic assignation:
In my case, I have many combo boxes that need to be bound in this fashion. rather than copy/paste a bunch of lines like above, I created the following loop:Dim obj As Object
Dim cmb As ComboBoxFor Each obj In MainTab.TabPages(1).Controls
With obj
If LCase(TypeName(obj)) = "combobox" Then <– you can change this to textbox or listbox, etc.cmb = CType(obj, ComboBox) <– must do a cast to set properties for the control you want to manipulate
Dim ds As New DataView(_MyDatabase_1DataSet.MyDataTable) <– note keyword New
cmb.DataSource = ds
cmb.DisplayMember = "RangeValue" <– for combo box, you have to set the display and
cmb.ValueMember = "RangeValue" <– the stored valueEnd If
End With
Next
-
WSsteve_skelton13
AskWoody Loungerthis issue has been resolved.
-
WSsteve_skelton13
AskWoody Loungeryeah that did it – thanks!
-
WSsteve_skelton13
AskWoody Loungerat present, there are 23 tables that need to be massaged. i am somewhat familiar with arrays but it’s been a while. currently i am trying to figure out how to insert the SQL into an array. It should be in the code block
If i = 0 Then
strSQL = “ALTER TABLE [” & tdf.Name & “] ADD [Confirmed How? (Code)] TEXT, [OES Notified Y/N] TEXT;”
INSERT SQL COMMAND INTO ARRAY
End If -
WSsteve_skelton13
AskWoody Loungeri have thougth about option 2 but i am not sure how i would write a single SQL statement that adds rows to several tables, and i’d prefer not to write the SQL to some other table and loop thru that. but i agree that it’s probably the case that DAO doesn’t want me to manipulate a table while i have it open. i was hoping there was some way to open a recordset such that it doesn’t lock the table when i operate on the table with a tabledef.
the preferred option would be to create an in-memory array of the SQL statements and then loop thru that; i can do that in .NET but i’ve never tried it in VBA/Access. but that sounds like a useful technique in any case… i also have a routine that does a UNION select on all these puppies (the tables i mean) and i can imagine doing that in VBA as well….
well, i will explore memory array options…
-
WSsteve_skelton13
AskWoody Loungeri believe so. the function opens with
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim rst As DAO.Recordset
Dim fld As DAO.Field‘ Fill collection
Set dbs = CurrentDbthen i create a table def so i can inspect the tables and only look at ones with a specific naming convention; if found instantiate a recordset to begin iterating thru the collection on the found table:
For Each tdf In dbs.TableDefs
If IsNumeric(Left(tdf.Name, 1)) = True Then
Set rst = dbs.OpenRecordset(tdf.Name, dbOpenTable)Since i am adding new columns, i set a flag and inspect the column names so i don’t try to add the same columns twice:
If Not rst.RecordCount = 0 Then
rst.Edit
i = 0For Each fld In tdf.Fields
If fld.Name = “OES Notified Y/N” Or fld.Name = “Confirmed How? (Code)” Then
i = 1
End If
Next fldThe fun is occurring when i try to add columns in those cases where the flag remains 0:
If i = 0 Then
strSQL = “ALTER TABLE [” & tdf.Name & “] ADD [Confirmed How? (Code)] TEXT, [OES Notified Y/N] TEXT;”
dbs.Execute strSQL
End Ifrst.MoveNext
in effect, the loop appears to be locking the tables automatically. i set up some debug.prints to check to make sure i’m not just hitting the same table over and over again but that part seems fine. i think somehow the way i am opening the recordset might be the problem but nothing strikes me at this time. I’ve done this before (well not in a loop) and adding columns using SQL works fine.
-
WSsteve_skelton13
AskWoody Loungerthat’s true but i’ve been using the same syntax as the second, working code. the only reason there’s the empty quotes is, i copy/pasted the VB code generated from a converted macro – which works in a new, empty DB but not on the one i am using. When i write the macro on the target DB, not only doesn’t it run but it won’t convert to VB.
In any case, I don’t think that is the issue – the same error occurs with or without the empty quotes.
-
WSsteve_skelton13
AskWoody Loungeryeah I thought of that yesterday – when i go to Add/Remove Programs and select Change from Office, there’s no option for ODBC drivers in the Access section.
-
WSsteve_skelton13
AskWoody LoungerIt might, if I had the machine and could look for the files myself. but the user is not a computer person and is in another city. i don’t see asking her to do file searches and registry edits as a solution. i was hoping a SP might be in order, but her machine is up to date. Since other people can run the app without problems, it is a config issue. But I am not going to direct her to do this sort of sleuthing.
anyhow, thanks for helping!
-
WSsteve_skelton13
AskWoody LoungerJust to make sure we’re talking about the same thing, the issue i have is, if a directory exists but has no files, i get a file/path error on trying to place files in the directory. if the directory does not exist, the system creates it and then places files – no error. if the directory exists and contains some file (any file), i can write new files to it. I don’t understand why this happens, as a newly created directory is also empty. It’s a little weird. I don’t like fixing it by ignoring the error, but that does fix it, in the sense that it behaves as desired.
-
WSsteve_skelton13
AskWoody Loungerwell, you still need the On Error Resume Next:
On Error Resume Next
If Dir(“C:RUGCalculator”) = “” Then
MkDir (“C:RUGCalculator”)
End Ifno need to check if empty – the system will place files in an empty existing folder, overwrite files in an existing folder or re-create the folder if it doesn’t exist.
-
WSsteve_skelton13
AskWoody LoungerThanks for the tip. i ended up doing this:
On Error Resume Next <– this forces the routine to complete; otherwise I get file/path error and execution halts.
If Dir("C:RUGCalculator") = "" Then
MkDir ("C:RUGCalculator")
Else
If Dir("C:RUGCalculator*.*") = "" Then
RmDir ("C:RUGCalculator")
MkDir ("C:RUGCalculator")
End If
End If -
WSsteve_skelton13
AskWoody LoungerI just finished reading an article from MS that states:
Applications cannot, however, ignore a return of SQL_SUCCESS_WITH_INFO return code on the SQLConnect, SQLDriverConnect, or SQLBrowseConnect. This is because messages other than 5701 and 5703 that do require action may be returned.
in the case of a timeout, the SQL Server error code is 01000, which cannot be suppressed. I read this to mean “since you succeeded in connecting, we kindly provide you with the option to login”. which is what I don’t want, but looks like I’ll have to live with it.
Previously, I got clever and built in a ping component in VBA to test the connection and that worked – meaning I could message out before actually connecting, but unfortunately the network I am on has several nodes that don’t allow ping, so most people couldn’t use the system. Those that couldn’t ping can, however, connect.
Well, thanks for trying!
-
WSsteve_skelton13
AskWoody Loungerthanks – i tried to do on error goto errorHandler and in errorHander: i did this:
MsgBox “Error: (” & Err.Number & “) ” & Err.Description, vbCritical
this is what happens: the connect fails, and i get the SQL Server timeout reply and the login dialog box (neither of which i’d like to see). the error itself from Access is
Error: (3059) Operation canceled by user.
Now, what appears to be happening is the ODBC call goes “outside” of Access and returns the error notification and login screen. Which makes some sense, as the error is raised in the ODBC call, not Access.
BTW, this is the connectstring:
“ODBC;Driver=SQL SERVER;SERVER=;UID=NFUR_user;PWD=;Database=NFUR;”
No need to implement DSN files – this code does the connection. I was hoping there’d be an option to suppress the login bit but I haven’t found anything along those lines.
-
WSsteve_skelton13
AskWoody Loungerwell, after spending a LOT of time on doing tabledefs, appends, etc etc I happened to notice Access has a provision for appending to — Another Database! — and it’s a one-liner:
DoCmd.RunSQL (“INSERT INTO
IN ‘\UNCDrivePathdbsskeltonXferDB.mdb’ SELECT * FROM ;”)
Sheesh!!!
There is the issue of duplicate submissions or people trying to do this while the targe db is locked, but still, there ya go.
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
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
-
Installing Feature Update Windows 11 24H2
by
geekdom
8 hours, 49 minutes ago -
Windows 11 Insider Preview build 27823 released to Canary
by
joep517
9 hours, 12 minutes ago -
Windows 11 Hotpatch
by
Hackmuss
4 hours, 4 minutes ago -
System Guard service error still won’t be fixed
by
Susan Bradley
9 hours, 51 minutes ago -
Operation ForumTroll: APT attack with Google Chrome zero-day exploit chain
by
Alex5723
4 hours, 2 minutes ago -
Troy Hunt of HaveIBeenPwned Phished
by
Lars220
1 hour, 3 minutes ago -
Microsoft Windows security auditing Code 5061
by
mpw
22 hours, 24 minutes ago -
Can’t display images in incoming Outlook 365 emails
by
WScopwriter
6 hours ago -
Windows 11 Insider Preview Build 26200.5510 early builds of 25H2
by
Alex5723
7 hours, 28 minutes ago -
0Patch : Micropatches released for SCF File NTLM Hash Disclosure Vulnerability
by
Alex5723
6 hours, 57 minutes ago -
Select multiple emails and they all open up!
by
CeeJay
1 day, 23 hours ago -
How to remove an update preview
by
Gunny
2 hours, 21 minutes ago -
Third party add ins reminder
by
Susan Bradley
1 day, 3 hours ago -
OTF, which backs Tor, Let’s Encrypt and more, sues to save its funding
by
Nibbled To Death By Ducks
1 day, 17 hours ago -
Updating Windows 10 to Windows 11: 23H2 or 24H2?
by
Still Anonymous
2 days, 3 hours ago -
How can I update “Explorer Patcher”
by
WSplanckster
2 days, 5 hours ago -
Check out the home page for Signal
by
CAS
2 days, 3 hours ago -
Windows 11 and Trial version of MS Office
by
Tex265
2 days, 2 hours ago -
Windows 11 Insider Preview build 26120.3585 (24H2) released to BETA
by
joep517
2 days, 10 hours ago -
Windows 11 Insider Preview build 26200.5510 released to DEV
by
joep517
2 days, 10 hours ago -
Windows 11 Insider Preview Build 26100.3624 (24H2) released to Release Preview
by
joep517
2 days, 10 hours ago -
Limits on User Names
by
CWBillow
2 days, 7 hours ago -
MS-DEFCON 4: Mixed bag for March
by
Susan Bradley
7 hours, 3 minutes ago -
Non Apple Keyboards
by
pmcjr6142
8 hours, 19 minutes ago -
How to delete your 23andMe data – The Verge
by
AJNorth
2 days, 5 hours ago -
7 common myths about Windows 11 (Microsoft AD)
by
EyesOnWindows
2 days, 2 hours ago -
Error updating to Win11 0x8024a205
by
bmeacham
2 hours, 22 minutes ago -
default apps
by
chasfinn
1 day, 10 hours ago -
Will MS Works 4 work in MS Win 11?
by
MileHighFlyer
2 hours, 8 minutes ago -
Adding links to text in Word 2000
by
sgeneris
2 days, 9 hours ago
Recent blog posts
- System Guard service error still won’t be fixed
- Third party add ins reminder
- MS-DEFCON 4: Mixed bag for March
- Classic and Extended Control Panel — no need to say goodbye
- Things you can do in 2025 that you couldn’t do in 2024
- Revisiting Windows 11’s File Explorer
- Planning ahead for migration
- Woody Leonhard (1951–2025)
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.