I have a maintenance Database with Main Form as header containing Vehicle Information and Controls (Eg. Year, make, Model etc. And Navigation Controls and Buttons To Edit Information for selected Unit)
My Sub Form is data sheet view for the Service History (Eg. Start Date, Engine Hrs, Deadline, Fault Description, Corrective Action, End Date, tech)
I am trying to have a label visibe in my main form [FormServiceHistory] only when Criteria is met from my subform [SubFormServiceHistory] Object Name[TBLservicehistory]
Criteria: Visible Only If: DEADLINE= True and EndDate Is Null
I have a Query that will generate the unit numbers that meet that criteria to use for my Deadline report if that could be used to make things easier.
But In wold Also Like DEADLINE Label to be Visible in the header Only if that Criteria is met.
I was able to get this to work eliminating the Date criteria, however I cannot Seem to get this to work using the Date criteria (Alone or with Deadline Criteria)
I was Not able to use And in the original code so I Dimmed as per code below.
I was getting a mis-match error. EndDate is a Date/Time Field in the underlying table so I Dim EndDate as Date. It still had mis-match error.
Now I am getting Run-Time error 91
I Click on Debug and VBA Highlights my [Deadline=] Line in the Code Builder. Any help would be appreciated.
Also If Some time a code to add to this to refresh Automatically without having to leave record and go back to record to see results would be nice.
Any Help would be appreciated. Thank You
MS Access 2007 Win 7 Pro x64
Code:
Private Sub Form_Current()
Dim Deadline As CheckBox
Dim EndDate As Date
Deadline = Forms![FormServiceHistory]![TBLservicehistory].Form![Deadline]
EndDate = Forms![FormServiceHistory]![TBLservicehistory].Form![EndDate]
If Deadline = True And (EndDate = Null) Then
Me.Label299.Visible = True
Else
Me.Label299.Visible = False
End If
End Sub