473,418 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

strangest hanging problem with re-attaching functions...

ARC
I have some functions that will allow a user to attach to a different
back-end database. I added this functionality to the program Ribbon in a
custom Access 2007 app. I have 2 ways to attach to a different back end db.
One is through a browse function. So the ribbon button option calls a macro
that runs a procedure that allows the user to browse to the back-end db,
then re-attaches the tables.

So for the browse button, A macro is launched: StartProgram("Other"). If
"Other" is the mode, I put up a browse dialogue in the StartProgram
function.

This works fine. All tables get properly re-attached, and the program
re-loads everything. Now for the problem.

I just added a new twist to the above where they can define their own
database locations into a table: tDatabaseLocations, the idea being that
they can switch to different databases at a single click, without browsing.
So, on program startup, I programatically add ribbon buttons for each db
that they define, and put an onAction call on the button (see proc below).
Each programmatic button I create is followed by a number. So when the
ribbon is built, it will have a series of buttons with button names such as
BtnOpenCustomDb1, BtnOpenCustomDb2, etc.. By finding the number at the end,
I know which db this relates to in their tDatabaseLocations entry.

The code below will show the correct db name, so the logic is working
(message box line that is commented out). The kicker is that it will get all
the way through all of the code in the proc called on the very last line:
Call StartProgram(dbnm)

However, when stepping through the code, when control is returned to this
calling proc (after running the Call StartProgram(dbnm) line), the program
just hangs. Since StartProgram uses many of the same variables, such as db,
rs, i, etc. I tried using different names in this proc, such as ddb, rrs,
ii, etc. All had no effect. I tried adding the DoEvents line, again no luck.
Lastly, I tried setting IRibbonControl to nothing and db to nothing, again
no affect.

So it will run all code in the StartProgram proc, but when it returns to the
proc below (WhichDbClicked), the program hangs. It appears to be treating
the call as a dialog (where it won't continue on to the last line until
StartProgram is complete). I think if it would simply execute the exit sub
line, while StartProgram is doing it's thing, all would be well.

Any ideas why it would be hanging?


Sub WhichDbClicked(control As IRibbonControl)
On Error GoTo ErrRtn
'
Dim ddb As Database, rrs As Recordset, recno As Integer, ii As Integer, dbnm
As String
recno = Right(control.ID, 1)
Set ddb = CurrentDb()
Set rrs = ddb.OpenRecordset("tDatabaseLocations", DB_OPEN_SNAPSHOT)
rrs.MoveFirst
ii = 1
Do Until ii = recno
ii = ii + 1
rrs.MoveNext
Loop
'MsgBox "Database Selected: " & rrs!DBInternalName
dbnm = rrs!DbLocation
rrs.Close
ddb.Close
Set ddb = Nothing
Set IRibbonControl = Nothing
DoEvents
Call StartProgram(dbnm)
Exit Sub
'
'
ErrRtn:
MsgBox Err.Number & " - " & Err.Description & ", Function: WhichDbClicked",
vbInformation
Exit Sub
End Sub

--
Andy
Aug 30 '07 #1
1 1685
ARC
Ok, I figured this out, but for the life of me I can't figure the "why" of
it.

Instead of using the line: Call StartProgram(dbnm) and passing the full
datapath: "C:\pc experts\develop\IQOFF2007\DatabaseNorth.accdb"

I added these 2 lines:

TempVars("WhichDb").Value = dbnm
Call StartProgram("Custom")

Then in StartProgram, if the passing variable is "Custom", I set a variable
DataPath to TempVars!WhichDb, then did the reconnecting of tables.

And oddly enough, the code now works perfectly. So the short of it is that
it had something to do with passing a long path to the StartProgram
function. The line causing the hang would have evaluated to a call like
this:

Call StartProgram("C:\pc experts\develop\IQOFF2007\DatabaseNorth.accdb")
I wonder why that would be?
Aug 31 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Harlan Messinger | last post by:
A publication style guide indicates that for a table heading like the following, Table 3. Wheat and rye harvest in European countries in years that end in 3 or 7 or when a new prime minister...
25
by: Shannon Jacobs | last post by:
Maybe there is a simple trick here, and I'm not spotting it... Is there a guru of CSS hanging around here who can help out? The page in question has a multi-column table with a list of links in...
0
by: Onin Tayson | last post by:
Hi All, How can I make my RadioButtonList to have a hanging indent when the text wraps to the next line? Example: O This is the default behavior when the text wraps.
5
by: David C. Allen | last post by:
I have a vb.net app that is controling excel 2000 thru the com interop interface. I have referenced the excel 9.0 library and have cut down the code in the problem subroutine to this: Dim...
0
by: ourspt | last post by:
Hi, In our application (web application in ASP.NET/VB.NET with SQL Server database), we have a situation where it is hanging due to double post back. In other words, if I have a check box on a...
6
by: Adrian | last post by:
Hi there My VB Code looks something like that: ************************************************************** Dim oShellApplication = CreateObject("Shell.Application") Dim objWindow For Each...
1
by: =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?= | last post by:
Hello guys, I was wondering if anybody here had implemented a solution where Tables are aligned according to what the hanging indent tells us when there is a potential for the table overflowing...
5
by: Stanimir Stamenkov | last post by:
I'm trying to style an icon "hanging" below the first line of a heading and I've found interesting difference between Mozilla and the other browsers I'm trying with - Safari 3.1.1, Opera 9.27 and...
3
by: Microsoft | last post by:
Hi I have a c# program that continually runs 24/7 and performs a variety of tasks based on a timer. There is one routine that hangs every Saturday morning without fail. If I restart the...
2
by: kj | last post by:
Hi! I have a Pythonoob question. I have a script that hangs indefinitely at random times; the only thing to do at this point is to kill it. I'm looking for suggestions on how to troubleshoot...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.