Now I get a Type Mismatch error. Here is the updated code
Code:
Option Compare Database
Public Function CalculateNextERONo()
Dim LastEntryNumber As String
Dim FirstClosedEntryNumber As String
Dim NextClosedSuffix As String
Dim OldPrefix As String
Dim OldSuffix As String
Dim NewPrefix As String
Dim NewSuffix As String
Dim NextERONo As String
'Return the Entry Number of the last record in the Sub Shop selected as LastEntryNumber.
Select Case Forms![Induct Gear]![Category Code].Value
Case "K"
LastEntryNumber = DMax("[Entry Number]", "[In Maintenance]", "[Sub Shop] = 'K'")
Case "S"
LastEntryNumber = DMax("[Entry Number]", "[In Maintenance]", "[Sub Shop] = '4'")
Case Else
Select Case Forms![Induct Gear]![Owning Organization].Value
Case "CLR-17 COMM CO XFA"
LastEntryNumber = DMax("[Entry Number]", "[In Maintenance]", "[Sub Shop] = 'L'")
Case "CLR-17 COMM CO XFB"
LastEntryNumber = DMax("[Entry Number]", "[In Maintenance]", "[Sub Shop] = 'U'")
Case "CLR-17 COMM CO XFC"
LastEntryNumber = DMax("[Entry Number]", "[In Maintenance]", "[Sub Shop] = 'V'")
Case "CLR-17 COMM CO TECHCON"
LastEntryNumber = DMax("[Entry Number]", "[In Maintenance]", "[Sub Shop] = 'W'")
Case Else
LastEntryNumber = DMax("[Entry Number]", "[In Maintenance]", "[Sub Shop] = '4'")
End Select
End Select
'Return the Entry Number of the first record in the Sub Shop with a "Closed" Status as FirstClosedEntryNumber.
Select Case Forms![Induct Gear]![Category Code].Value
Case "K"
FirstClosedEntryNumber = DMin("[Entry Number]", "[In Maintenance]", "[Sub Shop] = 'K'" And "[Status] = 'Closed'")
Case "S"
FirstClosedEntryNumber = DMin("[Entry Number]", "[In Maintenance]", "[Sub Shop] = '4'" And "[Status] = 'Closed'")
Case Else
Select Case Forms![Induct Gear]![Owning Organization].Value
Case "CLR-17 COMM CO MAINT"
FirstClosedEntryNumber = DMin("[Entry Number]", "[In Maintenance]", "[Sub Shop] = '4'" And "[Status] = 'Closed'")
Case "CLR-17 COMM CO XFA"
FirstClosedEntryNumber = DMin("[Entry Number]", "[In Maintenance]", "[Sub Shop] = 'L'" And "[Status] = 'Closed'")
Case "CLR-17 COMM CO XFB"
FirstClosedEntryNumber = DMin("[Entry Number]", "[In Maintenance]", "[Sub Shop] = 'U'" And "[Status] = 'Closed'")
Case "CLR-17 COMM CO XFC"
FirstClosedEntryNumber = DMin("[Entry Number]", "[In Maintenance]", "[Sub Shop] = 'V'" And "[Status] = 'Closed'")
Case "CLR-17 COMM CO TECHCON"
FirstClosedEntryNumber = DMin("[Entry Number]", "[In Maintenance]", "[Sub Shop] = 'W'" And "[Status] = 'Closed'")
Case Else
FirstClosedEntryNumber = DMin("[Entry Number]", "[In Maintenance]", "[Sub Shop] = '4'" And "[Status] = 'Closed'")
End Select
End Select
'Return the Prefix of the record who's Entry Number matches LastEntryNumber as OldPrefix.
OldPrefix = DLookup("[Prefix]", "In Maintenance", "Entry Number = " & LastEntryNumber)
'Return the Suffix of the record who's Entry Number matches LastEntryNumber as OldSuffix.
OldSuffix = DLookup("[Suffix]", "In Maintenance", "Entry Number = " & LastEntryNumber)
'Return the Suffix of the record who's Entry Number matches FirstClosedEntryNumber as NextClosedSuffix
NextClosedSuffix = DLookup("[Suffix]", "In Maintenance", "Entry Number = " & FirstClosedEntryNumber)
'If OldSuffix is 100, Reset to NextClosedSuffix and transition to the next prefix in the Sub Shop. Also defines NewPrefix.
If OldSuffix < 99 Then
NewSuffix = OldSuffix + 1
Else
Select Case OldPrefix
Case "HDA", "HDB", "HDC", "HDY", "HDZ"
NewPrefix = OldPrefix
Case "HDE"
NewPrefix = "HDD"
Case "HDX"
NewPrefix = "HDF"
Case Else
NewPrefix = "HD" & Chr(Asc(Right(OldPrefix, 1)) + 1)
End Select
NewSuffix = NextClosedSuffix
End If
'Combine NewPrefix and NewSuffix to make NextERONo
NextERONo = NewPrefix & NewSuffix
'Set InductGear_ERONumber to NextERONo
Forms![Induct Gear]![ERO Number] = NextERONo
End Function
the type mismatch is on this line
Code:
FirstClosedEntryNumber = DMin("[Entry Number]", "[In Maintenance]", "[Sub Shop] = 'L'" And "[Status] = 'Closed'")
Is it because I have two "where" conditions in the DMin function? If so, how else would I go about doing that?