J
Jani
Multiple users have a db but only one person is receiving the subject error.
I don't do much VB and the person that created the db is gone from the
company. Would someone be able to advise how this code should be fixed and
why only one person is having an issue with it. Thanks so much for your help!
Here's the code which I know is alot to wade through but I thought better to
include the whole thing rather than pick it apart and not have something that
is needed.
Function AvailDailyComparisonReport()
On Error GoTo 1
Dim rst As Recordset, counter As Integer
Dim startyear, startmonth As Integer
Set rst = CurrentDb.OpenRecordset("21DaysFromDateTo")
DoCmd.SetWarnings (WarningsOff)
' If Forms("frmReports").Daily Then - USED TO ALLOW DAILY COMPARISON OF
OEE COMPONENTS. ALTHOUGH THE REPORTS WERE ACCURATE - TOO CONFUSING - NOW ONLY
ALLOWING MONTHLY. Mark Smith 5/15/06
' DoCmd.OpenQuery "Clear21DaysFromDateTo"
' counter = 21
' Do
' rst.AddNew
' rst.Fields("Date").Value = month(Forms("frmReports").DateTo.Value
- counter) & "/" & day(Forms("frmReports").DateTo.Value - counter) & "/" &
year(Forms("frmReports").DateTo.Value - counter)
' rst.Update
' counter = counter - 1
' Loop Until counter = 0
' If Forms("frmReports").ExcludeNoDemand And
Forms("frmReports").ExcludeNoLabor Then
' DoCmd.OpenQuery "AvailCreateComparisonReportData - w/oNDw/oNL -
Daily"
' Else
' If Forms("frmReports").ExcludeNoDemand Then
' DoCmd.OpenQuery "AvailCreateComparisonReportData - w/oND -
Daily"
' Else
' If Forms("frmReports").ExcludeNoLabor Then
' DoCmd.OpenQuery "AvailCreateComparisonReportData - w/oNL -
Daily"
' Else
' DoCmd.OpenQuery "AvailCreateComparisonReportData -All -
Daily"
' End If
' End If
' End If
' DoCmd.RunMacro "TurnonWarnings"
' DoCmd.OpenReport "AvailComparisonReport - All - Daily", acPreview
' Else
Set rst = CurrentDb.OpenRecordset("12MonthsFromDateTo")
DoCmd.OpenQuery "Clear12MonthsFromDateto"
counter = 12
startmonth = month(Forms("frmReports").DateTo.Value)
startyear = year(Forms("frmReports").DateTo.Value) - 1
Do
If startmonth > 12 Then
startmonth = 1
startyear = startyear + 1
End If
rst.AddNew
rst.Fields("Date").Value = startmonth & "/" & "1" & "/" & startyear
rst.Update
counter = counter - 1
startmonth = startmonth + 1
Loop Until counter = 0
If Forms("frmReports").ExcludeNoDemand And
Forms("frmReports").ExcludeNoLabor Then
If Forms("frmReports").Shift.Value = "*" Then
If Forms("frmReports").ComparisonRow.Value = "shift" Then
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-w/oNDw/oNL-Monthly-Shift"
Else
DoCmd.OpenQuery "AvailCreateComparisonTable - w/oNDw/oNL -
Monthly"
End If
Else
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-w/oNDw/oNL-Monthly-Shift"
End If
Else
If Forms("frmReports").ExcludeNoDemand Then
If Forms("frmReports").Shift.Value = "*" Then
If Forms("frmReports").ComparisonRow.Value = "shift" Then
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-w/oND-Monthly-Shift"
Else
DoCmd.OpenQuery "AvailCreateComparisonTable - w/oND -
Monthly"
End If
Else
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-w/oND-Monthly-Shift"
End If
Else
If Forms("frmReports").ExcludeNoLabor Then
If Forms("frmReports").Shift.Value = "*" Then
If Forms("frmReports").ComparisonRow.Value = "shift" Then
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-w/oNL-Monthly-Shift"
Else
DoCmd.OpenQuery "AvailCreateComparisonTable - w/oNL
- Monthly"
End If
Else
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-w/oNL-Monthly-Shift"
End If
Else
If Forms("frmReports").Shift.Value = "*" Then
If Forms("frmReports").ComparisonRow.Value = "shift" Then
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-All-Monthly-Shift"
Else
DoCmd.OpenQuery "AvailCreateComparisonTable - All -
Monthly"
End If
Else
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-All-Monthly-Shift"
End If
End If
End If
End If
DoCmd.RunMacro "TurnonWarnings"
DoCmd.OpenReport "AvailComparisonReport - Monthly", acPreview
' End If
Exit Function
1
MsgBox "There was an error during the execution of the command. Error
code: (" & Error & "). Refer to OEE Database User's Manual or contact
database administrator if the problem persists.", vbCritical
Exit Function
End Function
I don't do much VB and the person that created the db is gone from the
company. Would someone be able to advise how this code should be fixed and
why only one person is having an issue with it. Thanks so much for your help!
Here's the code which I know is alot to wade through but I thought better to
include the whole thing rather than pick it apart and not have something that
is needed.
Function AvailDailyComparisonReport()
On Error GoTo 1
Dim rst As Recordset, counter As Integer
Dim startyear, startmonth As Integer
Set rst = CurrentDb.OpenRecordset("21DaysFromDateTo")
DoCmd.SetWarnings (WarningsOff)
' If Forms("frmReports").Daily Then - USED TO ALLOW DAILY COMPARISON OF
OEE COMPONENTS. ALTHOUGH THE REPORTS WERE ACCURATE - TOO CONFUSING - NOW ONLY
ALLOWING MONTHLY. Mark Smith 5/15/06
' DoCmd.OpenQuery "Clear21DaysFromDateTo"
' counter = 21
' Do
' rst.AddNew
' rst.Fields("Date").Value = month(Forms("frmReports").DateTo.Value
- counter) & "/" & day(Forms("frmReports").DateTo.Value - counter) & "/" &
year(Forms("frmReports").DateTo.Value - counter)
' rst.Update
' counter = counter - 1
' Loop Until counter = 0
' If Forms("frmReports").ExcludeNoDemand And
Forms("frmReports").ExcludeNoLabor Then
' DoCmd.OpenQuery "AvailCreateComparisonReportData - w/oNDw/oNL -
Daily"
' Else
' If Forms("frmReports").ExcludeNoDemand Then
' DoCmd.OpenQuery "AvailCreateComparisonReportData - w/oND -
Daily"
' Else
' If Forms("frmReports").ExcludeNoLabor Then
' DoCmd.OpenQuery "AvailCreateComparisonReportData - w/oNL -
Daily"
' Else
' DoCmd.OpenQuery "AvailCreateComparisonReportData -All -
Daily"
' End If
' End If
' End If
' DoCmd.RunMacro "TurnonWarnings"
' DoCmd.OpenReport "AvailComparisonReport - All - Daily", acPreview
' Else
Set rst = CurrentDb.OpenRecordset("12MonthsFromDateTo")
DoCmd.OpenQuery "Clear12MonthsFromDateto"
counter = 12
startmonth = month(Forms("frmReports").DateTo.Value)
startyear = year(Forms("frmReports").DateTo.Value) - 1
Do
If startmonth > 12 Then
startmonth = 1
startyear = startyear + 1
End If
rst.AddNew
rst.Fields("Date").Value = startmonth & "/" & "1" & "/" & startyear
rst.Update
counter = counter - 1
startmonth = startmonth + 1
Loop Until counter = 0
If Forms("frmReports").ExcludeNoDemand And
Forms("frmReports").ExcludeNoLabor Then
If Forms("frmReports").Shift.Value = "*" Then
If Forms("frmReports").ComparisonRow.Value = "shift" Then
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-w/oNDw/oNL-Monthly-Shift"
Else
DoCmd.OpenQuery "AvailCreateComparisonTable - w/oNDw/oNL -
Monthly"
End If
Else
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-w/oNDw/oNL-Monthly-Shift"
End If
Else
If Forms("frmReports").ExcludeNoDemand Then
If Forms("frmReports").Shift.Value = "*" Then
If Forms("frmReports").ComparisonRow.Value = "shift" Then
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-w/oND-Monthly-Shift"
Else
DoCmd.OpenQuery "AvailCreateComparisonTable - w/oND -
Monthly"
End If
Else
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-w/oND-Monthly-Shift"
End If
Else
If Forms("frmReports").ExcludeNoLabor Then
If Forms("frmReports").Shift.Value = "*" Then
If Forms("frmReports").ComparisonRow.Value = "shift" Then
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-w/oNL-Monthly-Shift"
Else
DoCmd.OpenQuery "AvailCreateComparisonTable - w/oNL
- Monthly"
End If
Else
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-w/oNL-Monthly-Shift"
End If
Else
If Forms("frmReports").Shift.Value = "*" Then
If Forms("frmReports").ComparisonRow.Value = "shift" Then
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-All-Monthly-Shift"
Else
DoCmd.OpenQuery "AvailCreateComparisonTable - All -
Monthly"
End If
Else
DoCmd.OpenQuery
"QryAvailCreateComparisonTable-All-Monthly-Shift"
End If
End If
End If
End If
DoCmd.RunMacro "TurnonWarnings"
DoCmd.OpenReport "AvailComparisonReport - Monthly", acPreview
' End If
Exit Function
1
MsgBox "There was an error during the execution of the command. Error
code: (" & Error & "). Refer to OEE Database User's Manual or contact
database administrator if the problem persists.", vbCritical
Exit Function
End Function