I have table with three fields the Status, BeginDate, and End date, I would like to find a record that starts on/before the BeginDate and ends on/After FinishDate. i created a module to query the table, when i call the function the txtbox remains empty.
here is what I have So far.
Module1
Option Compare Database
Option Explicit
Public Function UnitStatus(BeginDate As Date, Finishdate As Date)
Dim strStatus As String
Dim tblUnitStatus As String
CurrentDb.OpenRecordset ("Select * From tblunitstatus")
strStatus = "SELECT tblUnitStatus.Status FROM tblUnitStatus WHERE tblUnitStatus.BeginDate <=(DateSerial(Year(Date), 1, 1) AND tblUnitStatus.FinishDate >=(DateSerial(Year(Date), 1, 1)"
End Function
Private Sub Form_Load()
Me.lblDate1.Caption = Format(((DateSerial(Year(Date), 1, 1))), "ddd")
Me.lblDay1.Caption = Format(((DateSerial(Year(Date), 1, 1))), "dd")
Me.TxtStatus1.value = UnitStatus(1 / 1 / 2010, 1 / 1 / 2010)
not sure why it does not work, I have been searching and have not found the answer yet
here is what I have So far.
Module1
Option Compare Database
Option Explicit
Public Function UnitStatus(BeginDate As Date, Finishdate As Date)
Dim strStatus As String
Dim tblUnitStatus As String
CurrentDb.OpenRecordset ("Select * From tblunitstatus")
strStatus = "SELECT tblUnitStatus.Status FROM tblUnitStatus WHERE tblUnitStatus.BeginDate <=(DateSerial(Year(Date), 1, 1) AND tblUnitStatus.FinishDate >=(DateSerial(Year(Date), 1, 1)"
End Function
Private Sub Form_Load()
Me.lblDate1.Caption = Format(((DateSerial(Year(Date), 1, 1))), "ddd")
Me.lblDay1.Caption = Format(((DateSerial(Year(Date), 1, 1))), "dd")
Me.TxtStatus1.value = UnitStatus(1 / 1 / 2010, 1 / 1 / 2010)
not sure why it does not work, I have been searching and have not found the answer yet