Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Handle date ranges outside current recorset?

Status
Not open for further replies.

millrat

Technical User
Dec 23, 2003
98
US
Hi there,

My DB is a daily log with a form which is searchable by using another form with a calendar control/combobox using code below;

Dim rst As DAO.Recordset
Dim strDate As String

If IsNull(cboDate) Then
Exit Sub
Else
' Set the combobox value as the recordsource for the form
strDate = "#" & Format(Me.cboDate, "mm\/dd\/yy") & "#"
Set rst = Forms!frmDailyLog.Recordset.Clone
rst.FindFirst "dtmDate= " & strDate
If Not rst.EOF Then
Forms!frmDailyLog.Bookmark = rst.Bookmark
End If
End If
' Close the form
DoCmd.Close acForm, "frmSelectDate"

My question is this;

If a date is selected which is outside the date range of recordset how can I get a Message Box to pop up and tell the user this then exit the sub? Currently it just goes to the 1st record.

Cheers,
millrat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top