From: DavidWillis on
Couldn't exit out the ms access program after process one of the
procedure call and need to kill it by using the
Task Manger. Without calling that procedure it doesn't have that
problem.

The procedure call is look something like this

Sub AutoFillNewRecord(F As Form)
Dim RS As Object, C As Control
Dim FillFields As String, FillAllFields As Integer

On Error Resume Next

' Exit if not on the new record.
If Not F.NewRecord Then MsgBox "Profile can only apply to new
record.": Exit Sub
If IsNull(Combo1109) Then MsgBox "Please select a profile.": Exit
Sub

' Goto the last record of the form recordset (to autofill form).
stLinkCriteria = "[ID]='" & Me![Combo1109] & "'"
stSql = "select * from [NEWUSA_PROFILE1] where " & stLinkCriteria
Set RS = CurrentDb.OpenRecordset(stSql)

' Exit if you cannot move to the last record (no records).
If Err <> 0 Then Exit Sub
' Get the list of fields to autofill.
ExcludeFields = ";" & F![AutoExcludeNewRecordFields] & ";"

' If there is no criteria field, then set flag indicating ALL
' fields should be autofilled.
FillAllFields = Err <> 0

F.Painting = False

' Visit each field on the form.
For Each C In F
' Fill the field if ALL fields are to be filled OR if the
' ...ControlSource field can be found in the FillFields list.
If (FillAllFields Or Not InStr(ExcludeFields, ";" & (C.Name) &
";") > 0) Then
C = RS(C.ControlSource)
End If
Next
Set RS = Nothing
F.Painting = True
''''''''''''''''''''' Class B '''''''''''''''''''''''''
[CLASS_B].Form.Painting = False
stSql = "select * from [CLASS_B_PROFILE] where " & stLinkCriteria
Set RS = CurrentDb.OpenRecordset(stSql)
For Each C In [CLASS_B].Form
' Fill the field if ALL fields are to be filled OR if the
' ...ControlSource field can be found in the FillFields list.
If (FillAllFields Or Not InStr(ExcludeFields, ";" & (C.Name) &
";") > 0) Then
C = RS(C.ControlSource)
End If
Next
Set RS = Nothing
[CLASS_B].Form.Painting = True
''''''''''''''''''''' Class B '''''''''''''''''''''''''

End Sub

What the procedure was doing is get the record from the table using
the SQL statement and then loop thur each
object on the current form on each control and copy the value that had
the same name from the table. After this
process is done everything were fine and I can quit this form and back
to MainMenu but the only problem were I couldn't quit the ms access
afterward. I think is got to do with memory resoure? I wonder if
anyone can help me out with this. Thanks

David
From: Marco Pagliero on
On 8 Feb., 18:08, DavidWillis wrote:
> Couldn't exit out the ms access program after process one of the
> procedure call and need to kill it by using the
> Task Manger. Without calling that procedure it doesn't have that
> problem.
Some years ago a very similar problem was kown to depend from not
explicite conditions in some IF, that is, not to write "= true" or "<>
0"in "if a then".

That is, "If Not F.NewRecord then" would cause the problem, "If Not
F.NewRecord=true then" would not. And so on:

"If IsNull(Combo1109) then" => "If IsNull(Combo1109)=true then"

"If (FillAllFields Or Not InStr(ExcludeFields, ";" & (C.Name) & ";") >
0) then" => "If (FillAllFields=true Or Not InStr(ExcludeFields, ";" &
(C.Name) & ";") > 0)=true then"

I don't know if this is relevant in your case, but you can give it a
try.

Greetings
Marco