hello,
i want to use the various startup code such as
AllowByPassKey
etc
as you no doubt know this only takes affect after a db restart, i want to force this in code... any ideas how?
my plan is to use command switches to parse a "lock"/"unlock" variable and then restat immediately (if unlock (default would be locked)) and open exclusively.
tnx
dan
26 15540 MMcCarthy 14,534
Recognized Expert Moderator MVP
Hi Dan
This is a property setting and can be controlled as follows: -
' disable bypass key
-
SetProperties "AllowBypassKey", dbBoolean, False
-
' enable bypass key
-
SetProperties "AllowBypassKey", dbBoolean, True
-
im sorry, i already know how to do that bit.
i need to know how to force a restart of currentdb
MMcCarthy 14,534
Recognized Expert Moderator MVP
You could try running a compact and repair which will compact the database and then close and reopen it. -
'------------------------------------
-
'- Compact the database. This only -
-
'- works if it is the only code in -
-
'- the function, and if the -
-
'- function is called from the last -
-
'- line of another VB function -
-
'------------------------------------
-
Function CompactandRepairDB()
-
On Error GoTo Err_CompactDB
-
-
CommandBars("Menu Bar"). _
-
Controls("Tools"). _
-
Controls("Database utilities"). _
-
Controls("Compact and repair database..."). _
-
accDoDefaultAction
-
-
Exit_Compactdb:
-
-
Exit Function
-
-
Err_CompactDB:
-
-
If Err.Number = 3356 Then
-
Resume Exit_Compactdb
-
Else
-
MsgBox Err.Description
-
Resume Exit_Compactdb
-
End If
-
-
End Function
-
i used a shell command as such
(simplified)
call shell(strFilename, 1)
docmd.quit
this works but i cannot open the db in exclusive mode because it is still open
any ideas similar?
NeoPa 32,556
Recognized Expert Moderator MVP
You will never be able to call for an exclusive open on a database from within the code of the very same database. That is simply illogical.
You can try to be clever and set something up with a Cmd or Bat file. That won't be too straightforward though, depending on the complexity you want to use.
Would you consider it sloppy to open a blank database first and then the original with exclusive rights? would that work?
MMcCarthy 14,534
Recognized Expert Moderator MVP @Dan2kx
No because as NeoPa says you cannot open "another" database exclusively while you are still in the original database and therefore it is still open.
Remember you are dealing with instances of the database. It doesn't matter if the database is empty or not. It's the application that counts.
I meant to open a blank database, close the original and then open the original again with /excl and then close the blank as such;
call shell(blank,1)
docmd.quit
call shell(original /excl)
docmd.quit
therefore the original would not be open.
would that work?
NeoPa 32,556
Recognized Expert Moderator MVP
If the original is not open then the code must have stopped running. ==> no opening of any other database.
Control must be passed to some other process, which in turn, and only after the calling process (original Access database code) has been determined to have completed, may open the original database in exclusive mode.
Does that make sense?
mayb...
if i open a blank database with new code to open the first on open that would work!?
or else a batch file then?
if i was to use a batch file how would i get it to wait until access was closed before reopening?
yes! works!
so from main db, i have a command switch, if /cmd = "unlock" turn startups back on, open next (blank) database and close main.
autoexec macro in blank db runs code which opens original /excl and closes blank. to slow down the automated process and allow /excl time for first db to close, don't use digital signature on blank db, or add in a msgbox
shell command used as prviously sated.
unless anyone can suggest a better method thaks for the help guys!
Dan out (for now)
NeoPa 32,556
Recognized Expert Moderator MVP
In a CMD file (far better than BAT - although either would work for your requirements) I usually do a simple rename of a file to itself to determine if it is safe to continue.
If that works (NOT ERRORLEVEL = 1) then the file is free to be opened. If not, then loop and try again, optionally prompting the operator to determine if they're still interested.
The beauty of a CMD (or BAT) file is that the actual file can be created on the fly by the database code, precisely defined for the job in hand and without depending on anything external to the database to be left lying around.
im afraid i have no real experience with bat/cmd files other than simple tasks, could you point me in a useful direction for this particular requirement? i am attracted to the simplicity rather than my more complicated fix.
NeoPa 32,556
Recognized Expert Moderator MVP
As an working example, and to illustrate all the points I think you'll need, I knocked up a working version below. You may well have to make changes, and you may want to incorporate some flexibility into it (Name of MDB; Folder path; etc), but fundamentally this is what you need. TestMDB.Cmd - CD /D %HomePath%
-
-
:CheckLoop
-
Ren MyDB.Mdb MyDB.Mdb
-
If ErrorLevel 1 GoTo CheckLoop
-
-
MyDB.Mdb
NeoPa 32,556
Recognized Expert Moderator MVP
As a sort of PS I googled "cmd tricks" and found Coding Horror: Stupid Command Prompt Tricks. Typing HELP on the command line is one of the basic ways of learning what you can do with it. It has a couple of other tips too though.
Everything else I found seemed to be cracking related so I won't send you in that direction.
I am using a UNC (\\DataDrive\Folder) path to locate my DB and this throws a spanner in the works for CMD file?
NeoPa 32,556
Recognized Expert Moderator MVP
It shouldn't be that much of a problem. The example I used was simply an example. Try instead something similar to : TestMDB.Cmd - :CheckLoop
-
Ren \\DataDrive\Folder\MyDB.Mdb MyDB.Mdb
-
If ErrorLevel 1 GoTo CheckLoop
-
-
\\DataDrive\Folder\MyDB.Mdb
I dont mean to keep throwing up new obsticles... but i am using a hidden folder and it doesnt seem to work..
NeoPa 32,556
Recognized Expert Moderator MVP
I think you need to give more information.
Hidden folders don't automatically stop access. They're simply not displayed by default (when browsing). What is your specific problem here?
my file path is
\\nlg-plwardv1\holiday$\holidays.mdb
i tried your .cmd solution but got a "file not found error"
i dont really wantto map the drive
cheers
and sorry for being difficult
Dan
NeoPa 32,556
Recognized Expert Moderator MVP
This doesn't look like an issue with hidden shares to me. I've just run a test on viewing the contents of a hidden share and it worked perfectly as expected.
What response do you get when you run (from a command prompt) ? - DIR \\nlg-plwardv1\holiday$
ok the file is not visible (that is hidden too) could that be the problem then?
NeoPa 32,556
Recognized Expert Moderator MVP
im having some trouble with a command file (that is written from access vb module)
can anyone see any errors with this? doesnt do anything as far as i can tell
the last line is for deleting itself
this is just a tester ATM, i plan to use the code to pull the current version of an MDE if the one that is running is out of date (on open).
Cheers
figured it out had colon in wrong place Sign in to post your reply or Sign up for a free account.
Similar topics
by: KaXo |
last post by:
$r_socket = IO::Socket::INET->new(
PeerAddr => "10.0.26.78",
PeerPort => 17990,
Proto => 'tcp',
Timeout => 1
);
......................
if ($r_socket && $r_socket->connected()) {...
|
by: Lauren Wilson |
last post by:
A2K app:
Question: is the flagged line (<<<) below necessary. If that line is
needed, what effect does it have (if any) on the fact that the very
same database is the linked back end db?
...
|
by: Agnes |
last post by:
In my one form, the user need to search many field, e.g customer name,
country name, currency.. etc
They are using the same conMaster , So, when Should I closed the connection
??
1st) if the user...
|
by: Generic Usenet Account |
last post by:
I have been able to recreate a problem that I am having with the file
stream using the simple sample code given below.
I am trying to read the number of lines in a file, relying on the
getline...
|
by: Marc |
last post by:
I'm building a Windows service that writes log messages via TraceListeners.
I assume Trace.Close() is useful for garbage collection, but I'm not sure
where to call it in the Windows service. Any...
|
by: Zytan |
last post by:
I have a log class that makes a synchronized TextWriter like so, in
the constructor:
StreamWriter sw = new StreamWriter(filename);
tw = TextWriter.Synchronized(sw);
In the destructor,...
|
by: raddrummer |
last post by:
Hi there,
I'm woking on a function that takes the input from a form (including Payroll Contact), uses it as a query parameter, runs the query, and then emaills out a custom .xls file using the...
|
by: =?Utf-8?B?Skw=?= |
last post by:
HI,
I have this problem since yesterday. Every time I try to close Outlook, I
can't, I get the error"MS Outlook has encountered a problem and needs to
close. we are sorry.... Just that it...
|
by: Eric B. |
last post by:
Is it a bad idea to do both once I'm done with an object?
Eric B.
|
by: PJ6 |
last post by:
OK this is annoying... after I installed VS2008 to try it out, apparently an
update was made to the behavior VS2005. Now when I close and reopen a
document I'm working on, the Undo history is...
|
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...
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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: 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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |