Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message Form doesn't close

Status
Not open for further replies.

Lhuffst

Programmer
Jun 23, 2003
503
0
0
US

I used the code from thread702-936087 and while it works. The progressMessage form and the frmMeterReturn_Main do display but I can't seem to get the progressMessage form to close I was getting error 2585 so I added the line on error Resume Next
Code:
Private Sub Form_Current()
 
DoCmd.OpenForm "FrmMeterReturn_main", acNormal, "", "", , acHidden

nill = getMeterInfo()
    
    On Error Resume Next
    DoCmd.Close acForm, "ProgressMessage"
   Forms("FrmMeterReturn_main").Visible = True
   Forms("ProgressMessage").Visible = False
End Sub



Public Function getMeterInfo()
  Dim db As DAO.Database, rst As DAO.Recordset
   Dim frm As Form, ctl As Control
 
  Set db = CurrentDb()
  
   Set rst = db.OpenRecordset("meterinfo", dbOpenDynaset)    'Set object reference to the Table.
   rst.MoveLast
   rst.MoveFirst
      
   DoCmd.OpenForm "Progressmessage"                         'Open the ProgressBar form.
   DoEvents                                                 'Allow ProgressBar form to fully refresh.
 
   Set frm = Forms!progressmessage                          'Set object reference to the ProgressBar form.
   Set ctl = frm!ProgressBar7                                'Set object refernce to the ProgressBar.
   lblRead.Visible = True
   frm.Caption = "Reading Records! . . ."                   'Set the Caption of the form.
  
   ctl.Max = rst.RecordCount                                 'Set the Max Count of the bar.
    
   Do
      ctl = ctl + 1                                          'ProgressBar is enumerated here!
        rst.MoveNext
   Loop Until rst.EOF
     
   On Error Resume Next                                     'added this line to try and close form
   
   DoCmd.Close acForm, "Progressmessage", acSaveNo          'Close the ProgressBar form . . . Done!
   Screen.MousePointer = 0
   
   Set rst = Nothing                                        'return used resources to the database (close out)
   Set db = Nothing
   
End Function
 
Hi,

It could be related to you still having references pointing to the form objects.

Have you tried clearing the variable references before trying to close the form?

Code:
Do While Not rst.EOF
      ctl = ctl + 1 'ProgressBar is enumerated here!
      rst.MoveNext
Loop

Set ctl = Nothing
Set frm = Nothing
   
DoCmd.Close acForm, "Progressmessage"

Regards,
1DMF

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
I don't know what was wrong but when I moved the code to another form, it works fine. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top