exit application bug

G

Guest

Hi,

I have a very usual bug. I have an mde database that is split in a server.
Each user have their own copy of the front end of the database. I don't have
any problems with it so far (crossing my finger) but the only problem that I
have is when the user exit the application. When the user exit the
application I have code to ask if the user really want to exit.

I have a form
on current:
Private Sub Form_Current()
Populate_Description

End Sub

before update:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[PART_NUMBER]) = True Then
MsgBox "You must enter Part Number."
Me.[PART_NUMBER].SetFocus
Exit Sub
End If
If IsNull(Me.COUNTRY) = True Then
MsgBox "You must enter a Country."
Me.COUNTRY.SetFocus
Exit Sub
End If
If IsNull(Me.Status) = True Then
MsgBox "You must enter a Status."
Me.Status.SetFocus
Exit Sub
End If
End Sub

When the user exit/terminate the database it exits okay but there is a MS
Access empty screen that just can't exit. When you click on the exit [X]
control on the upper right hand of the screen it does not close the screen.
The only way to close the screen is to hold down the Ctrl + Alt + Del and end
the task there to close the empty screen. This is driving me crazy to figure
out why there is this stubbon screen that just won't close. The funny thing
is when I as the Admin open the database and the Input Form and then exit the
database, it completely exits. It only happen to other users except me. All
users are using Access 2003. Please help. Thank you in advance.
 
P

Pieter Wijnen

For one you should set the Cancel Flag
Seccondly I myself hate to be bombarded with MsgBox'es

I Prefer something Like this

Public Sub Form_BeforeUpdate(Cancel As Integer)

Dim C As Access.Control

For Each C In Me.Controls
Select Case C.ControlType
Case acComboBox, acTextBox
With C
If Instr(.Tag , "Required Entry") > 0 Then
If IsNull(.Value) Then
Beep
.SetFocus
Cancel = True
Exit For
End If
End If
End With
End Select
Next ' C

End Sub

That said the problem you're having is traditionally mostly due to open
Objects (Recordsets)
Make sure to close all Recordsets Explicitly in your code

ie

If Not Rs Is Nothing Then
Rs.Close : Set Rs = Nothing
End If

It Might also be an idea to issue a Me.Undo on closing of the form (to undo
"unfinnished" Entries)

HTH

Pieter


"E-mail report using Lotus Notes rather t"
 
G

Guest

Hi Pieter,

Thank you for the swift response. On the Input form, I have a text field
called part_# and on the text field the On Change Event I have the following
code. (Basically this code is to auto-populate the description field if the
user select the part_# using combo text menu). Can you tell me what I am
doing wrong with this. The code is working perfectly in the form. You might
be right there is something not closed completely in this form to cause my
bug. Because when user don't tough this form or open any other form besides
this form there is no problem exiting the application. It's only this form
is giving me the exit application bug. Thanks.

Sub Populate_Description()
Dim dbs As Database, qdf As QueryDef, strSQL As String, rs As Recordset

Set dbs = CurrentDb
strSQL = "SELECT * FROM [Product List] WHERE [Part Number] = '" &
Forms![Input Data Form]!PART_NUMBER & "'"
Set qdf = dbs.CreateQueryDef("", strSQL)

Set rs = qdf.OpenRecordset

qdf.Close

If Not rs.EOF Then
Forms![Input Data Form]!DESCRIPTION = rs!DESCRIPTION
End If
rs.Close
dbs.Close

Set rs = Nothing
Set qdf = Nothing
Set dbs = Nothing


End Sub

Pieter Wijnen said:
For one you should set the Cancel Flag
Seccondly I myself hate to be bombarded with MsgBox'es

I Prefer something Like this

Public Sub Form_BeforeUpdate(Cancel As Integer)

Dim C As Access.Control

For Each C In Me.Controls
Select Case C.ControlType
Case acComboBox, acTextBox
With C
If Instr(.Tag , "Required Entry") > 0 Then
If IsNull(.Value) Then
Beep
.SetFocus
Cancel = True
Exit For
End If
End If
End With
End Select
Next ' C

End Sub

That said the problem you're having is traditionally mostly due to open
Objects (Recordsets)
Make sure to close all Recordsets Explicitly in your code

ie

If Not Rs Is Nothing Then
Rs.Close : Set Rs = Nothing
End If

It Might also be an idea to issue a Me.Undo on closing of the form (to undo
"unfinnished" Entries)

HTH

Pieter


"E-mail report using Lotus Notes rather t"
Hi,

I have a very usual bug. I have an mde database that is split in a
server.
Each user have their own copy of the front end of the database. I don't
have
any problems with it so far (crossing my finger) but the only problem that
I
have is when the user exit the application. When the user exit the
application I have code to ask if the user really want to exit.

I have a form
on current:
Private Sub Form_Current()
Populate_Description

End Sub

before update:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[PART_NUMBER]) = True Then
MsgBox "You must enter Part Number."
Me.[PART_NUMBER].SetFocus
Exit Sub
End If
If IsNull(Me.COUNTRY) = True Then
MsgBox "You must enter a Country."
Me.COUNTRY.SetFocus
Exit Sub
End If
If IsNull(Me.Status) = True Then
MsgBox "You must enter a Status."
Me.Status.SetFocus
Exit Sub
End If
End Sub

When the user exit/terminate the database it exits okay but there is a MS
Access empty screen that just can't exit. When you click on the exit [X]
control on the upper right hand of the screen it does not close the
screen.
The only way to close the screen is to hold down the Ctrl + Alt + Del and
end
the task there to close the empty screen. This is driving me crazy to
figure
out why there is this stubbon screen that just won't close. The funny
thing
is when I as the Admin open the database and the Input Form and then exit
the
database, it completely exits. It only happen to other users except me.
All
users are using Access 2003. Please help. Thank you in advance.
 
P

Pieter Wijnen

You should never close the Current Db (dbs.Close) , at least not after
Access '97.
You should also use the AfterUpdate event instead of change in this case, as
change fires for every keystroke

HTH

Pieter


"E-mail report using Lotus Notes rather t"
Hi Pieter,

Thank you for the swift response. On the Input form, I have a text field
called part_# and on the text field the On Change Event I have the
following
code. (Basically this code is to auto-populate the description field if
the
user select the part_# using combo text menu). Can you tell me what I am
doing wrong with this. The code is working perfectly in the form. You
might
be right there is something not closed completely in this form to cause my
bug. Because when user don't tough this form or open any other form
besides
this form there is no problem exiting the application. It's only this
form
is giving me the exit application bug. Thanks.

Sub Populate_Description()
Dim dbs As Database, qdf As QueryDef, strSQL As String, rs As Recordset

Set dbs = CurrentDb
strSQL = "SELECT * FROM [Product List] WHERE [Part Number] = '" &
Forms![Input Data Form]!PART_NUMBER & "'"
Set qdf = dbs.CreateQueryDef("", strSQL)

Set rs = qdf.OpenRecordset

qdf.Close

If Not rs.EOF Then
Forms![Input Data Form]!DESCRIPTION = rs!DESCRIPTION
End If
rs.Close
dbs.Close

Set rs = Nothing
Set qdf = Nothing
Set dbs = Nothing


End Sub

Pieter Wijnen said:
For one you should set the Cancel Flag
Seccondly I myself hate to be bombarded with MsgBox'es

I Prefer something Like this

Public Sub Form_BeforeUpdate(Cancel As Integer)

Dim C As Access.Control

For Each C In Me.Controls
Select Case C.ControlType
Case acComboBox, acTextBox
With C
If Instr(.Tag , "Required Entry") > 0 Then
If IsNull(.Value) Then
Beep
.SetFocus
Cancel = True
Exit For
End If
End If
End With
End Select
Next ' C

End Sub

That said the problem you're having is traditionally mostly due to open
Objects (Recordsets)
Make sure to close all Recordsets Explicitly in your code

ie

If Not Rs Is Nothing Then
Rs.Close : Set Rs = Nothing
End If

It Might also be an idea to issue a Me.Undo on closing of the form (to
undo
"unfinnished" Entries)

HTH

Pieter


"E-mail report using Lotus Notes rather t"
Hi,

I have a very usual bug. I have an mde database that is split in a
server.
Each user have their own copy of the front end of the database. I
don't
have
any problems with it so far (crossing my finger) but the only problem
that
I
have is when the user exit the application. When the user exit the
application I have code to ask if the user really want to exit.

I have a form
on current:
Private Sub Form_Current()
Populate_Description

End Sub

before update:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[PART_NUMBER]) = True Then
MsgBox "You must enter Part Number."
Me.[PART_NUMBER].SetFocus
Exit Sub
End If
If IsNull(Me.COUNTRY) = True Then
MsgBox "You must enter a Country."
Me.COUNTRY.SetFocus
Exit Sub
End If
If IsNull(Me.Status) = True Then
MsgBox "You must enter a Status."
Me.Status.SetFocus
Exit Sub
End If
End Sub

When the user exit/terminate the database it exits okay but there is a
MS
Access empty screen that just can't exit. When you click on the exit
[X]
control on the upper right hand of the screen it does not close the
screen.
The only way to close the screen is to hold down the Ctrl + Alt + Del
and
end
the task there to close the empty screen. This is driving me crazy to
figure
out why there is this stubbon screen that just won't close. The funny
thing
is when I as the Admin open the database and the Input Form and then
exit
the
database, it completely exits. It only happen to other users except
me.
All
users are using Access 2003. Please help. Thank you in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top