Re: CommonDialog returns wrong context



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


.



Relevant Pages

  • Re: CommonDialog returns wrong context
    ... I tried setting the flag: it does not solve my problem. ... Probably because my app is calling the 'Print' CommonDialog (for which the ... connectionstrings are pointing to a database in the current path. ... connectionstring in the form load procedure does not help because of the Ado ...
    (microsoft.public.vb.bugs)
  • Re: Finding last record in month for each of several types of reco
    ... used to flag the records which are the "Last Record of the Month" ... "Richard Buttrey" wrote: ... >>In your database, ... >>secondary sort key and the Date as the 3rd sort key. ...
    (microsoft.public.excel.programming)
  • Re: Send email
    ... I just want it to send automatically once i open the database without ... calls your email sub and set that macro to run automatically at startup. ... After the Send/Display call, you'll set that flag to True to ...
    (microsoft.public.access.formscoding)
  • Re: Changing auto-Negotiate settings
    ... In Smitty ethernet --> Change / Show Characteristics of an Ethernet Adapter ... The change can be made to the database with the -P flag. ... Subject: Changing auto-Negotiate settings ...
    (AIX-L)
  • Identify Last occurance
    ... I can do a little VB and have a reasonable grasp of Access but I have a ... My database has a table of Projects, their status and a table of how the ... In the above example I would be seeking to flag up Status Change ID record 2 ...
    (microsoft.public.access.modulesdaovba)

Loading