Spoke too soon!

S

SuzyQ

I though that I had worked out my data corruption problem, but appearantly
it's not resolved yet. (See messages under "Network Connection may have
been..." 06/01/2009-06/02/09)

I am no longer getting the message that Access cannot access the file -
network connection may have been lost. Instead, what is happening now is
when I go to save a particular form (not sure if it's happening on all forms
because I'm only working on on in particular, but I have tried others without
an issue) or if I try to run it - Access just closes. It doesn't happen
every time, but it is happening too often.

This is what I've done so far this morning to try to correct the problem,
but it hasn't worked yet.

I went through all my forms, reports, and modules and copied the code to
text files. Then I set the has module property to no. Then I
compacted/repaired the database. Then I put all the code back to the
forms/reports/modules. Then I started modifying again and the same thing
happened. So I decided to open a blank database and import all the objects
to it. Before I did, I set all the has module properties to no again. Then
I packed the database again. Then I exported into new blank database. Then
I opened the new database and put the code back to the proper objects. Still
having issues. Access just closes either during a save or when trying to run
the form I am modifying. I have NOT edited any code while the form is
running so that didn't do it.
 
S

SuzyQ

Sorry, I should have included this in what I did. Yes, after each time I put
code back to the object, I compiled and then saved. The database itself has
a lot of code, some of it complicated, but the form in question is fairly
straight forward and simple. Code below in case there is something that I
have done wrong and/or there is a better way to write it. (I'm fairly an
Access novice)

The form is unbound - it enables/disables text boxes and combo boxes
depending the report selected (cmbReport) the data for this control comes
from tblReports which is a table that holds a list of reports (report name,
report title, various boolean fields that determine what data the report
needs to run - i.e. employee, fund, fiscalYear, fiscalMonth, from/to dates,
project, etc) the code also skips over fields that have been "auto filled"
(tab stops set, but these fields have the option of being filled in manually
or by selecting from other combo boxes - I skip over them if programmed to be
filled in.

START CODE

Option Compare Database
Option Explicit

Private Sub cmbFiscalYear_AfterUpdate()
If Not IsNull(Me.cmbFiscalYear) Then
Me.txtFromDate = Me.cmbFiscalYear.Column(1) 'set from date for
fiscal year select
Me.txtToDate = Me.cmbFiscalYear.Column(2) 'set to date for fiscal
year select

'set cursor in the next necessary field for data entry
If Me.cmbProject.Enabled Then
Me.cmbProject.SetFocus
Else
If Me.cmbJob.Enabled Then
Me.cmbJob.SetFocus
Else
If Me.cmbEmployee.Enabled Then
Me.cmbEmployee.SetFocus
Else
Me.cmdReport.SetFocus
End If
End If
End If
Else 'blank out the from/to dates
Me.txtFromDate = ""
Me.txtToDate = ""
End If
End Sub

Private Sub cmbFMonth_AfterUpdate()
If Not IsNull(Me.cmbFMonth) Then
Me.PayPeriod = "" 'blank out pay period box
Me.cmbFiscalYear = "" 'blank out fiscal year box
Me.txtFromDate = Me.cmbFMonth.Column(1) 'set from date with start
fiscal month date
Me.txtToDate = Me.cmbFMonth.Column(2) 'set to date with end fiscal
month date
Me.cmbFiscalYear = Me.cmbFMonth.Column(3) 'set fiscal year with
fiscal year of fiscal month selected

'set cursor in next necessary field for input
If Me.cmbFiscalYear.Enabled Then
Me.cmbFiscalYear.SetFocus
Else
If Me.cmbProject.Enabled Then
Me.cmbProject.SetFocus
Else
If Me.cmbJob.Enabled Then
Me.cmbJob.SetFocus
Else
If Me.cmbEmployee.Enabled Then
Me.cmbEmployee.SetFocus
Else
Me.cmdReport.SetFocus
End If
End If
End If
End If
Else 'blank out the from and to dates
Me.txtFromDate = ""
Me.txtToDate = ""
End If
End Sub

Private Sub cmbReport_AfterUpdate()
If Not IsNull(Me.cmbReport) Then
'Project CODE necessary for report to run
If Me.cmbReport.Column(2) = True Then
Me.cmbProject.Enabled = True
Else
Me.cmbProject.Enabled = False
End If

'employee necessary for report to run
If Me.cmbReport.Column(3) = True Then
Me.cmbEmployee.Enabled = True
Else
Me.cmbEmployee.Enabled = False
End If

'job code necessary for report to run
If Me.cmbReport.Column(4) = True Then
Me.cmbJob.Enabled = True
Else
Me.cmbJob.Enabled = False
End If

'from/to dates necessary for report to run
If Me.cmbReport.Column(5) = True Then
Me.cmbFMonth.Enabled = True
Me.PayPeriod.Enabled = True
Me.txtFromDate.Enabled = True
Me.txtToDate.Enabled = True
Else
Me.cmbFMonth.Enabled = False
Me.PayPeriod.Enabled = False
Me.txtFromDate.Enabled = False
Me.txtToDate.Enabled = False
End If

'fiscal year necessary for report to run
If Me.cmbReport.Column(6) = True Then
Me.cmbFiscalYear.Enabled = True
Else
Me.cmbFiscalYear.Enabled = False
End If

'fund necessary for report to run
If Me.cmbReport.Column(7) = True Then
Me.cmbFund.Enabled = True
Else
Me.cmbFund.Enabled = False
End If

'fiscal month necessary for report to run
If Me.cmbReport.Column(8) = True Then
Me.cmbFMonth.Enabled = True
Else
If Me.cmbReport.Column(5) = False Then
Me.cmbFMonth.Enabled = False
End If
End If
Else
Me.cmbProject.Enabled = False
Me.cmbEmployee.Enabled = False
Me.cmbJob.Enabled = False
Me.PayPeriod.Enabled = False
Me.txtFromDate.Enabled = False
Me.txtToDate.Enabled = False
Me.cmbFiscalYear.Enabled = False
Me.cmbFund.Enabled = False
Me.cmbFMonth.Enabled = False
End If

End Sub

Private Sub cmbReportCategory_AfterUpdate()
Me.cmbReport.Requery
Me.cmbReport.Enabled = True
End Sub

Private Sub cmdClose_Click()
DoCmd.Close
End Sub

Private Sub cmdReport_Click()
Dim runReport As Boolean
runReport = True

If IsNull(Me.cmbReport) Then
MsgBox "Select Report"
runReport = False
Else
If Me.cmbReport.Column(2) = True Then 'project code required
If IsNull(Me.cmbProject) Then
MsgBox "Report requires project code selection"
runReport = False
End If
End If
If Me.cmbReport.Column(3) = True Then 'employee required
If IsNull(Me.cmbEmployee) Then
MsgBox "Report requires employee selection"
runReport = False
End If
End If
If Me.cmbReport.Column(4) = True Then 'job code required
If IsNull(Me.cmbJob) Then
MsgBox "Report requires job code selection"
runReport = False
End If
End If
If Me.cmbReport.Column(5) = True Then 'from/to dates required
If IsNull(Me.txtFromDate) Then
MsgBox "Report requires from/to dates"
runReport = False
End If
If IsNull(Me.txtToDate) Then
MsgBox "Report requires from/to dates"
runReport = False
End If
End If
If Me.cmbReport.Column(6) = True Then 'fiscal year required
If Len(Trim(Me.cmbFiscalYear)) <> 4 Then
MsgBox "Report requires four digit fiscal year"
runReport = False
End If
End If

If Me.cmbReport.Column(7) = True Then 'fund required
If Me.cmbFund < 1 Or IsNull(Me.cmbFund) Then
MsgBox "Report requires fund"
runReport = False
End If
End If

If Me.cmbReport.Column(8) = True Then 'fiscal month required
If Me.cmbFMonth < 8 Or IsNull(Me.cmbFMonth) Then
MsgBox "Report requires valid fiscal month"
runReport = False
End If
End If
End If
If runReport = True Then
DoCmd.OpenReport Me.cmbReport, acViewPreview
End If
End Sub

Private Sub PayPeriod_AfterUpdate()
If Not IsNull(Me.PayPeriod) Then
Me.cmbFMonth = "" 'blank out fiscal month box
Me.cmbFiscalYear = "" 'blank out fiscal year box
Me.txtFromDate = Me.PayPeriod.Column(1) 'set from date with start
date from pay period
Me.txtToDate = Me.PayPeriod.Column(2) 'set to date with end date
from pay period

'set cursor in the next necessay field for data input
If Me.cmbFiscalYear.Enabled Then
Me.cmbFiscalYear.SetFocus
Else
If Me.cmbProject.Enabled Then
Me.cmbProject.SetFocus
Else
If Me.cmbJob.Enabled Then
Me.cmbJob.SetFocus
Else
If Me.cmbEmployee.Enabled Then
Me.cmbEmployee.SetFocus
Else
Me.cmdReport.SetFocus
End If
End If
End If
End If
Else 'blank out the from/to dates
Me.txtFromDate = ""
Me.txtToDate = ""
End If
End Sub

END CODE
 

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