Form erasing/deleting itself

Crilen007

Uhm, Title... *shrug*
Local time
Today, 03:41
Joined
Jun 13, 2003
Messages
531
I have a database that keeps track of people going on a cruise.

I am not the one who uses this database, I just maintain it.

Once in a while the most used form (the one to add and edit people on each account) deletes itself.

There is no code that would tell the form to erase itself, and the only one who modifies the code and the form is me, so its not like it tries to save the form, and only gets part way or something.

Any ideas where to look or what might be causing it?

Very odd.. Here is all the code on the main form.

Code:
Option Compare Database
Option Explicit

Private Sub cboAcct_AfterUpdate()
    DoCmd.ApplyFilter , "[CustID] = " & Me!cboAcct.Column(0)
    Me!cboAcct = ""
End Sub

Private Sub CBOCabin_AfterUpdate()
DoCmd.ApplyFilter , "[cabinNumber] = '" & Me!cboCabin.Column(0) & "'"
    Me!cboCabin = ""
End Sub

Private Sub cboCompany_AfterUpdate()
    DoCmd.ApplyFilter , "[CustID] = " & Me!cboCompany.Column(0)
    Me!cboCompany = ""
End Sub

Private Sub cboCompanyName_AfterUpdate()

    Me.RecordsetClone.FindFirst "[CustID] = " & Me!cboCompanyName.Column(0)
    
    If RecordsetClone.NoMatch Then
        MsgBox "Item Not Found"
    Else
        Me.Bookmark = Me.RecordsetClone.Bookmark
    End If
    
End Sub


Private Sub cboCompany_Enter()
    Me.cboCompany.Requery
End Sub

Private Sub cboDblPts_Enter()
    Me.cboDblPts.Requery
    
End Sub

Private Sub CboCustStat_Change()
Forms!frmRegistration!txtModDate = Now
End Sub

Private Sub cboHostID_DblClick(Cancel As Integer)
     DoCmd.OpenForm "frmHost", acNormal
End Sub

Private Sub cboLastName_AfterUpdate()
    DoCmd.ApplyFilter , "[CustID] = " & Me!cboLastName.Column(0)
    Me!cboLastName = ""
End Sub

Private Sub cboMonthPur_Enter()
    Me.cboMonthPur.Requery
    
End Sub

Private Sub cboSalesman_AfterUpdate()
    DoCmd.ApplyFilter , "[SignupSlsmNbr] = " & Me!cboSalesman.Column(1)
    Me!cboSalesman = ""
End Sub

Private Sub cboSlsmn_AfterUpdate()
Forms!frmRegistration!txtModDate = Now
End Sub



Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click
    DoCmd.GoToRecord , , acNewRec
    Me.txtCompanyName.Locked = False
    DoCmd.OpenForm "frmMainSearch"
    Me.txtCompanyName.SetFocus
Exit_cmdAddRecord_Click:
    Exit Sub
Err_cmdAddRecord_Click:
    MsgBox Err.Desciption
    Resume Exit_cmdAddRecord_Click:
End Sub

Private Sub cmdPreview_Click()
    DoCmd.OpenReport "rpt9807/08", acViewPreview, , "[custid]=" & Forms!frmRegistration![CustID]
End Sub

Private Sub cmdSeptember_Click()
    DoCmd.OpenReport "rpt9809", acViewPreview, , "[custid]=" & Forms!frmRegistration![CustID]
End Sub

Private Sub cboHost_AfterUpdate()
    DoCmd.ApplyFilter , "[HostId] = " & Me!cboHost.Column(1)
    Me!cboHost = ""
End Sub

Private Sub cmdEdit_Click()
    Me.txtCompanyName.Locked = False
    Me.txtCompanyName.SetFocus
End Sub

Private Sub Form_Current()
   ' txtCompanyName.SetFocus
    'Me.cboMonthPur.Requery
End Sub
Private Sub HostID_DblClick(Cancel As Integer)
    DoCmd.OpenForm "frmHost", acNormal
End Sub

Private Sub HostID_Enter()
    Me.HostID.Requery
End Sub

Private Sub lstReports_DblClick(Cancel As Integer)
    Select Case lstReports
        Case 1
            DoCmd.OpenReport "rpt9807/08", acViewPreview, , "[custid]=" & Forms!frmRegistration![CustID]
        Case 2
            DoCmd.OpenReport "rpt9809", acViewPreview, , "[custid]=" & Forms!frmRegistration![CustID]
        Case 3
            DoCmd.OpenReport "rpt9810", acViewPreview, , "[custid]=" & Forms!frmRegistration![CustID]
        Case 4
            DoCmd.OpenReport "rpt9811", acViewPreview, , "[custid]=" & Forms!frmRegistration![CustID]
        Case 5
            DoCmd.OpenReport "rpt9812", acViewPreview, , "[custid]=" & Forms!frmRegistration![CustID]
        Case 6
            DoCmd.OpenReport "rpt9901", acViewPreview, , "[custid]=" & Forms!frmRegistration![CustID]
        Case 7
            DoCmd.OpenReport "rpt9902", acViewPreview, , "[custid]=" & Forms!frmRegistration![CustID]
        Case 8
            DoCmd.OpenReport "rpt9903", acViewPreview, , "[custid]=" & Forms!frmRegistration![CustID]
        Case 9
            DoCmd.OpenReport "rpt9904", acViewPreview, , "[custid]=" & Forms!frmRegistration![CustID]
        Case 10
            DoCmd.OpenReport "rpt9905", acViewPreview, , "[custid]=" & Forms!frmRegistration![CustID]
        Case 11
            DoCmd.OpenReport "rpt9906", acViewPreview, , "[custid]=" & Forms!frmRegistration![CustID]
        End Select
End Sub

Private Sub TS01DCP_AfterUpdate()
    Me.TS01Points = Me.TS01DCP * (Me.Percentage / 100)
End Sub

Private Sub txtCompanyName_Change()
Me.txtModDate = Now
End Sub

Private Sub txtCompanyName_Exit(Cancel As Integer)
    Me.txtCompanyName.Locked = True
End Sub
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click


    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_cmdDelete_Click:
    Exit Sub

Err_cmdDelete_Click:
    MsgBox Err.DESCRIPTION
    Resume Exit_cmdDelete_Click
    
End Sub

Its really odd. If you have any questions ill be watching this post, feel free to ask.
 
I have a large mdb which often deletes form object VBA code. This usually happens when I modify the code when in debug mode with the form open in form view.

Why is it doing this? I don't have a clue, but believe that it's related to a corrupt mdb or one on the verge of corruption. I recommend repairing and compacting often.

Maybe program bloat causes it. Access can be mysterious sometimes.
 
I'll do a repair and compress and see how it goes. It doesn't do it very often.
 

Users who are viewing this thread

Back
Top Bottom