473,397 Members | 2,116 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,397 software developers and data experts.

"Disconnect" back end from front end using VBA

Currently I have a button that allows the user to "Close Company" - at
the moment it doesn't do anything :D I would like the button to
"disconnect" the back end then show my Open Company form.

My question is:
1. Short of closing the application or deleting the linked tables, is
there a way to disconnect the user's front end from the common back
end using VBA?
2. Does disconnecting the user serve any purpose? I've read a lot of
posts about back end corruption, and kicking the user out of the
application, but nothing about disconnecting the back end.

Given the lack of discussion on the topic in this newsgroup (I haven't
found a thing) my assumption is that this is not possible. However,
would be happy if someone could confirm my suspicion.

Thanks to everyone in advance,

Kelii
Aug 29 '08 #1
9 8558
ARC
Hi Kelii,

I've never heard of code to disconnect from the back-end, however, there are
cases where you would want to disconnect, for example, if you had a menu
option to compact the back-end database. For compacting, you could not have
any tables linked to the back-end, so you would need to disconnect. The
only trick I know is to have a second database, which is blank, that
contains all the same tables, etc. Basically, you would refresh the links of
all tables to the blank database, then compact the true back-end db, then
refresh the links back to the real back-end.

As for serving a purpose, I don't think disconnecting (connecting to a blank
db) would serve any better purpose then simply closing the FE database
program with a macro, or vba, etc.

Hope that helps,

Andy

"Kelii" <ke****@yahoo.comwrote in message
news:32**********************************@x35g2000 hsb.googlegroups.com...
Currently I have a button that allows the user to "Close Company" - at
the moment it doesn't do anything :D I would like the button to
"disconnect" the back end then show my Open Company form.

My question is:
1. Short of closing the application or deleting the linked tables, is
there a way to disconnect the user's front end from the common back
end using VBA?
2. Does disconnecting the user serve any purpose? I've read a lot of
posts about back end corruption, and kicking the user out of the
application, but nothing about disconnecting the back end.

Given the lack of discussion on the topic in this newsgroup (I haven't
found a thing) my assumption is that this is not possible. However,
would be happy if someone could confirm my suspicion.

Thanks to everyone in advance,

Kelii
Aug 29 '08 #2
Kelii <ke****@yahoo.comwrote:
>Currently I have a button that allows the user to "Close Company" - at
the moment it doesn't do anything :D I would like the button to
"disconnect" the back end then show my Open Company form.

My question is:
1. Short of closing the application or deleting the linked tables, is
there a way to disconnect the user's front end from the common back
end using VBA?
2. Does disconnecting the user serve any purpose? I've read a lot of
posts about back end corruption, and kicking the user out of the
application, but nothing about disconnecting the back end.

Given the lack of discussion on the topic in this newsgroup (I haven't
found a thing) my assumption is that this is not possible. However,
would be happy if someone could confirm my suspicion.
I have a button on my Fleet Management app which allows the user to do a backup of
the backend data MDB. I also have two other buttons which zip and email the backend
data MDB to either themselves for backup purposes or to me for support purposes. So
the problem here is the same.

However any open forms or reports will lock the back end MDB file so a rename and
compact won't happen.

As I do not know which forms and reports the user might have left open when the click
on that button I run through some code that closes all open forms and reports, then
run the code doing the rename, compact back to the same file name and, if requested
do the zip and email.

' close all forms and reports
For Each frm In Forms
DoCmd.Close acForm, frm.Name
Next frm
DoEvents
For Each rpt In Reports
DoCmd.Close acReport, rpt.Name
Next rpt
DoEvents

DoEvents seems to be necessary to give things time to close. But maybe not
neccesary.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Aug 29 '08 #3
Kelii <ke****@yahoo.comwrote:
>2. Does disconnecting the user serve any purpose? I've read a lot of
posts about back end corruption, and kicking the user out of the
application, but nothing about disconnecting the back end.
Corruption only happens in that brief moment of time when a record is updated on a
form. That is when the record selector changes from a triangle to a pencil or from a
pencil back to a triangle or when the form is close. If a user is editing a record
on the computer screen but isn't actually saving that record then corruption won't
happen.

So not a big deal.

Tony

--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Aug 29 '08 #4
Andy, Tony:

Thanks for the prompt response. Given your thoughts, I think I can
pass on the whole disconnect thing and simply go with my Open Company
form in dialog mode.

I did think ahead to closing the various forms (for backup purposes as
well). I was quite proud of myself for using an array. I tried for a
few hours to figure out a way to only stop closing forms if they were
"dirty", but this effort ended in complete failure and confusion.

The piece that follows allows the user to check if any forms are open,
except as specified in the fx call.

Thanks again,

Kelii

Public Function kleCheckForOpenForms(ParamArray varFormArray() As
Variant) As String
On Error GoTo Error_Handler
'Sample procedure call kleCheckForOpenForms("frmSwitchboard",
"frmOpenCompany")
'Function output:
'"ExtraFormsOpen"
'"NoExtraFormsOpen"

Dim intFormsCount As Integer
Dim intFormName As Integer
Dim intFormArrayValue As Integer
Dim intI As Integer

'Use UBound fx to determine upper limit of array
'Note array values start at 0 and count up
'Find number of forms open and compare to array size
intFormsCount = Forms.Count - 1
If intFormsCount UBound(varFormArray()) Then
'Too many forms open
kleCheckForOpenForms = "ExtraFormsOpen"
GoTo Exit_Procedure
End If

'Check open forms against name of forms that are ok
'to be open
'Iterates through every open form
For intFormName = intFormsCount To 0 Step -1
'Iterates through every value in the array
'and compare array value with form name
intI = intFormsCount
For intFormArrayValue = UBound(varFormArray()) To 0 Step -1
If Forms(intFormName).Name =
varFormArray(intFormArrayValue) Then
Exit For
Else
intI = intI - 1
End If
If intI = -1 Then
'All forms checked, none match
kleCheckForOpenForms = "ExtraFormsOpen"
GoTo Exit_Procedure
End If
Next
Next

'If here, then no extra forms are open
kleCheckForOpenForms = "NoExtraFormsOpen"

Exit_Procedure:
On Error Resume Next
Exit Function
Error_Handler:
Select Case Err
Case Else
MsgBox "Error: " & Err.Number & vbCr & Err.Description
Resume Exit_Procedure
End Select
End Function
Aug 29 '08 #5
Kelii <ke****@yahoo.comwrote:
>The piece that follows allows the user to check if any forms are open,
except as specified in the fx call.
Sure but I just closed all forms. I have very, very few forms in my apps that aren't
bound to the backend in one form or another.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Sep 1 '08 #6
Tony,

I'm interested in the code you posted above. When you posted it, I
assumed that it was perhaps a reporting application with no data
entry, but based on your last post, perhaps not.

I implemented similar code in my application, but soon abandoned the
effort due to conflicts with my error handlers. For example, if I have
a data entry form open, with an incomplete record in progress, the
form closing code you suggest above would prompt my error handler and
cause an inelegant exit from the form.

Of course, the user has the option to select "Cancel" in the error
handler's message box, which stopped the form from closing. However,
as I tested the application, it seemed to me that the application
became "clunky," and I preferred to have the user close the forms
themselves.

Given the above (sorry if its a bit of a wandering thought pattern), I
wondered if you have any thoughts about how to handle the form closing
gracefully?

Kelii

P.S. I have chosen to setup my backend tables with required properties
set to No, then use VBA to check for completeness and accuracy, with
custom error handlers for most (I hope all) situations.
Sep 3 '08 #7
Tables are linked. Are back-ends linked? I think not but I'm prepared
to be educated.
To unlink tables we can just Drop them.

Sub temp()
On Error Resume Next
Do
Err = 0
CurrentProject.Connection.Execute "DROP Table " &
CurrentProject.Connection.Execute("SELECT TOP 1 '[' & [NAME] & ']'
From MSysObjects WHERE Type = 6")(0)
Loop Until Err <0
End Sub

I've never had back-end corruption, or front-end either that I recall.
Probably, I am doing something wrong.

On Aug 28, 11:55*pm, Kelii <kel...@yahoo.comwrote:
Currently I have a button that allows the user to "Close Company" - at
the moment it doesn't do anything :D I would like the button to
"disconnect" the back end then show my Open Company form.

My question is:
1. Short of closing the application or deleting the linked tables, is
there a way to disconnect the user's front end from the common back
end using VBA?
2. Does disconnecting the user serve any purpose? I've read a lot of
posts about back end corruption, and kicking the user out of the
application, but nothing about disconnecting the back end.

Given the lack of discussion on the topic in this newsgroup (I haven't
found a thing) my assumption is that this is not possible. However,
would be happy if someone could confirm my suspicion.

Thanks to everyone in advance,

Kelii
Sep 3 '08 #8
Kelii <ke****@yahoo.comwrote:
>I'm interested in the code you posted above. When you posted it, I
assumed that it was perhaps a reporting application with no data
entry, but based on your last post, perhaps not.
No, not at all. That's a very full featured app with lots of data entry and inquiry
forms.
>Given the above (sorry if its a bit of a wandering thought pattern), I
wondered if you have any thoughts about how to handle the form closing
gracefully?
Yes, that can be a problem but generally the users should have all the other forms
closed when they return to the main menu.
>P.S. I have chosen to setup my backend tables with required properties
set to No, then use VBA to check for completeness and accuracy, with
custom error handlers for most (I hope all) situations.
I completely agree with that. You never know when you need to add some records in a
different fashion with incomplete data such as doing a data import or bulk record
add.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Sep 5 '08 #9
Tony,

Thanks for the responses. This is really my first complete application
and I have no formal training or related work experience; so your
thoughts are helpful and valuable to me.

Lyle,

Thanks for the suggestion. Based on my quick review of VBA help, the
Drop Table query would delete the table from the project, which is not
really the action I'm looking for. I seem to have accomplished the
same thing (at least from the user's standpoint) simply by closing all
the forms and basically opening a Windows Common File Open Save dialog
for the new company to be selected.

Thanks again to you both for you insight.

Kelii
Sep 5 '08 #10

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

Similar topics

0
by: Yi-Yu Chou | last post by:
Dear python users, I tried to display 4 vtkRendererWidgets arrayed in a 2x2 grid, and the arrangement would be like : X | Y --| -- Z | T
15
by: voipcanada | last post by:
is there any thing we can write to keep the right txt to the = sign in the preg_split. from the following lines DST-NUMBER-IN=0033512877596, DST-NUMBER-OUT=98751#33512877596,...
6
by: Dmitri | last post by:
Hi there, Does anybody know what is DB2 UDB admin API equivalent to "db2 terminate" command? Some background: I'm developing monitoring application(http://chuzhoi_files.tripod.com). I want...
2
by: Lee | last post by:
I have a Word template that is set to merge with our client database. After I run the merge, I merge to a new document, and then save the new document. When I reopen this saved document, it prompts...
5
by: Jozef | last post by:
Hello, I have an Access XP database that has attachments to a BE database that has a password. The attachments work fine, until I run some code that modifies a BE table (adding a field). I do...
1
by: Burak SARICA | last post by:
I am searching for a way to solve this problem (the below post) too. Anyone may help? I get the same error, at the Connect() line. Even i've added the ASPNET account to the fax's security tab. (in...
30
by: Pep | last post by:
Is it best to include the code "using namespace std;" in the source or should each keyword in the std namespace be qualified by the namespace tag, such as std::cout << "using std namespace" <<...
2
by: Chameleon | last post by:
I have a BIG php output and I start to transmit after client's request. What happen on server when client press "Stop"? PHP continues to send data? Where? Until the end?
4
by: lander | last post by:
I've read the page life cycle thing in msdn, still, i'm getting a bit confused of thinking how all the things are going under the hood... I know that when page loading, that the controls'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.