Preventing a from from being opened - if already open

Preventing a from from being opened - if already open

Post by RICK WEB » Sun, 09 Aug 1998 04:00:00



Can anyone help me with this problem?

Is there way to code an application to keep a user from opening a "second"
occurrance of a form that is already open?  

Would appreciate any suggestions:


 
 
 

Preventing a from from being opened - if already open

Post by Mark Knau » Sun, 09 Aug 1998 04:00:00


The standard way to determine if a form is open is to attempt to attach()
to it.  If attach() fails, then the form is not open.  If attach()
succeeds, that means the form is open and you can then call
formVar.bringToTop() to bring the form to the top and give it focus.

Remember:  The attach() method for a form takes the form "title" as a
parameter, not the form file name.

if formVar.attach("This Great Application 2.0")

     rather than

if formVar.attach(THISFORM.FSL)

Mark



> Can anyone help me with this problem?

> Is there way to code an application to keep a user from opening a
"second"
> occurrance of a form that is already open?  

> Would appreciate any suggestions:




 
 
 

1. Mail merge from Access try to open an already open DB

Hi,

I need some help with my database project in VB 6 using Access & Word
2000.

What I'm trying to do is a mail merge in Word 2000 coded in VB from my
Access application. The problem is that the mail merge always tried to
open a new copy of my Access Database (that is already open) and that
cause me to see a warning message: "The database has been placed in a
state by user 'Admin' on machine 'machinename' that prevents it from
being opened or locked." I see this warning 3 times, then Word finally
 do the mail merge but I now have 3 copies of access running (without
files opened). Then if I close the Word application from my VB code,
Word close and also my running Access application, leaving me only
with my 3 access windows without files opened. Can anybody help me?
here is my code:

'dclare les variables
Dim strFormLetterFile As String
Dim strDataSourceDB As String
Dim strDataSourceQuery As String
Dim strConnect As String
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim wrdMerger As Word.MailMerge

    'nom du formulaire pr-publipost ouvrir
    strFormLetterFile = "C:\mes documents\fr_fax_acc.dot"
    strDataSourceDB = "C:\WINDOWS\Bureau\estimation ACC- word.mdb"
    strDataSourceQuery = "qry_tlcopieur"

    'Create a new instance of word
    Set wrdApp = New Word.Application

    'Open the Word document - the form letter to be sent out
    Set wrdDoc = wrdApp.Documents.Add(strFormLetterFile)

    'establish a MailMerge object using this formletter
    Set wrdMerger = wrdDoc.MailMerge

    With wrdMerger
        .MainDocumentType = wdFormLetters
        .OpenDataSource Name:=strDataSourceDB, _
            LinkToSource:=True, AddToRecentFiles:=False, _
            Connection:="QUERY " & strDataSourceQuery

        .Destination = wdSendToNewDocument
        .DataSource.FirstRecord = 1
        .DataSource.LastRecord = 1
        .Execute
    End With

    'ferme le 1er word contenant le formulaire fusionner
    wrdDoc.Close wdDoNotSaveChanges
    ActiveDocument.SaveAs "ppp.doc"   'TODO: ask filename to user
    ActiveDocument.Close wdDoNotSaveChanges
    wrdApp.Quit

    'return focus to VB and notify when done
    Me.SetFocus
    MsgBox "merge process completed"

    Set wrdApp = Nothing

Thanks
Pierre

2. ODBC Direct?

3. vb conflict to open DB already open with Access (error 3356)

4. Write Conflict

5. Error opening file (already opened)

6. Need help!

7. Linked Server - Server: Msg 7399 - It is already opened exclusively by another user

8. sample CLP scripts to create new instance/database and configure ODBC/cli?

9. How to check if a cursor is already open

10. Linked Server - Server: Msg 7399, - It is already opened exclusively by another user

11. Clear Excel data using VB Script - File Already Open

12. Linked Server - Server: Msg 7399 - It is already opened exclusively by another user

13. Databse "tempdb: already open...