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 15526
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
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
Expert Mod 16PB
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?
@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
Expert Mod 16PB
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
Expert Mod 16PB
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
Expert Mod 16PB
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
Expert Mod 16PB
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
Expert Mod 16PB
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
Expert Mod 16PB
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
Expert Mod 16PB
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
Expert Mod 16PB
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: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
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...
|
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...
| |