Newbie Application.Quit Question 
Author Message
 Newbie Application.Quit Question

Hi,

    Essentially I'm trying to write a little pop up form in access everytime
I turn on my computer to let me know if someone has a birthday within 15
days or not.  My first form automatically starts when the database is
opened.  It is called frmOpener.  Here is the code for frmOpener.
Essentially what the form does is pull a record set.  If the recordset is
not null the form opens another form which has a list of all the people with
upcoming birthdays within 15 days.  If the recordset is null then Access
quits by using the Application.Quit command.  The problem is that after
Access quits a dialog box pops up saying "Cannot find file....mydb etc...".
It seems like Access is closing so fast that it still wants to do something
but then since it did close it can't find what it needs.  Any suggestions?

Thank you,

CS

Private Sub Form_Load()

    Dim oConn As New ADODB.Connection
    Dim myDB
    Set myDB = CurrentDb
    oConn.Provider = "Microsoft.Jet.OLEDB.4.0"
    oConn.ConnectionString = "data source = " & myDB.Name
    oConn.Open

    Dim rs
    Set rs = New ADODB.Recordset
    Dim msg As String
    msg = "Select * from qryBirthDaysComing "
    rs.Open msg, oConn, 1, 3

    If not IsNull(rs) Then
        MsgBox "You have Birthdays within 15 days."
        DoCmd.OpenForm ("frmBirthDays")
    Else
        Application.Quit
    End If

    rs.Close
    Set rs = Nothing
    oConn.Close
    Set oConn = Nothing
    DoCmd.Close acForm, "frmOpener"

End Sub



Fri, 26 Dec 2003 11:07:03 GMT  
 Newbie Application.Quit Question
Your problem is being caused right here,
-->     Application.Quit <--

     rs.Close
     Set rs = Nothing
     oConn.Close
     Set oConn = Nothing
     DoCmd.Close acForm, "frmOpener"

You're quiting w/o releaseing the recordset out of memory... Consider making
your sub a function and the Quiting something like this...

 Private Sub Form_Load()
    if fBirthdays then
         MsgBox "You have Birthdays within 15 days."
         DoCmd.OpenForm ("frmBirthDays")
    Else
        Application.Quit
    Endif
 End sub

Function fBirthdays as Boolean
     Dim oConn As New ADODB.Connection
     Dim myDB
     fBirthdays = False ' To show there are no B'days
     Set myDB = CurrentDb
     oConn.Provider = "Microsoft.Jet.OLEDB.4.0"
     oConn.ConnectionString = "data source = " & myDB.Name
     oConn.Open

     Dim rs
     Set rs = New ADODB.Recordset
     Dim msg As String
     msg = "Select * from qryBirthDaysComing "
     rs.Open msg, oConn, 1, 3

     If not IsNull(rs) Then
        fBirthays = True 'Birthday was found
    End If

     rs.Close
     Set rs = Nothing
     oConn.Close
     Set oConn = Nothing
     DoCmd.Close acForm, "frmOpener"

 End Sub

--
-Francisco

Quote:
> Hi,
<SNIP>
>The problem is that after
> Access quits a dialog box pops up saying "Cannot find file....mydb
etc...".
> It seems like Access is closing so fast that it still wants to do
something
> but then since it did close it can't find what it needs.  Any suggestions?

> Thank you,

> CS



Sat, 27 Dec 2003 03:43:02 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Newbie Application.Quit Question

2. Newbie question: access 97 ONLY from VB application

3. Newbie Simple Question: How to place icon on desktop during setup of created application

4. Newbie Question-Application Wizard - How to!

5. newbie question - trying to start applications with .vbs file

6. Newbie Question - IIS application

7. VB Applications and Access (Newbie question)

8. Newbie Question---Database structure for custom accounting application

9. Newbie Question - porting an access application

10. Newbie question:- Application.System.PrivateProfileString.

11. Newbie Question - Packaging Applications From 32 Bit Systems to 16 Bit Systems

12. Another Newbie Question: Searching the VB application

 

 
Powered by phpBB® Forum Software