Re: CommonDialog returns wrong context
- From: nb0512 <nb0512@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 23 Jan 2007 06:14:00 -0800
Thanks Mike. I am aware that copying the database is really quick and DIRTY
if only because it will eventually lead to a hard disk with copies of the
database all over it as users choose different directories to save their
print files. But hey, I was kinda desparate.
On the 'probably best' solution, I fully agree and I am using a string
variable now. But parts of this app I wrote when I was still using Adodc
controls on my forms and I didn't -and stil don't- know how to get a string
var in it's connection string at design time ? Redefining the
connectionstring in the form load procedure does not help because of the Ado
pre-load events.
I will try the flag thing; it sounds good
Thanks
..
"MikeD" wrote:
.
"nb0512" <nb0512@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C08FA153-1645-4D50-94E4-F3540657BDF9@xxxxxxxxxxxxxxxx
In my app I give the user the possibility to print a form using the
CommonDialog control. If no printer is attached, the MS Document Imager
automatically pops up. This also gives the user the option to save. If
user
does this, and selects the directory X to save the print in, the app
continues in this directory after the CommonDialog closes. On the form the
app returns to I have an Ado control which has a relative
connectionstring;
so the app now starts looking for the database in directory X -does not
find
it there of course- and crashes.
Since the Ado fires events even before the form loads, I cannot correct
this.
The workaround I implemented copies the database to the directory where
the
print was saved; (this to satisfy the Ado pre-load events) and then on the
form I reset the connectionstring to the correct value. This works OK, but
is
far from elegant.
Is there anyone who has encountered thsi same problem and is there a real
solution for it ? Thanks !!!
Copying the database as a means of solving this "problem" is probably one of
the worst ways (if not THE worst way) of "solving" it.
Before you show the dialog box, assign cdlOFNNoChangeDir to the Flags
property (you should OR this to any other flags you assign to this
property). This flag is actually intended for the Open and Save As dialogs,
but it *might* solve your problem as well.
Alternatively (and probably best), assign the database path to a variable
and always use that variable. It sounds like you're relying on the current
directory which is NOT good because as you've found out, the current
directory can change. If your database file is located in the same folder as
your application EXE file, you could also alternatively use App.Path.
--
Mike
Microsoft MVP Visual Basic
- Follow-Ups:
- Re: CommonDialog returns wrong context
- From: nb0512
- Re: CommonDialog returns wrong context
- References:
- Re: CommonDialog returns wrong context
- From: MikeD
- Re: CommonDialog returns wrong context
- Prev by Date: Re: CommonDialog returns wrong context
- Next by Date: for zilvia: extremely intelligent premium nntp access - afba ahtisog - (1/1)
- Previous by thread: Re: CommonDialog returns wrong context
- Next by thread: Re: CommonDialog returns wrong context
- Index(es):
Relevant Pages
|
Loading