Programming Up and Down Buttons to show dates in c
I am trying to show appointmentdate in the FromDate text field and use up and down buttons to requery date according to the dates in ther query and refresh the form with current data. I am really having problems and really need to get this accomplished. All help is greatly appreciated. I did not see a place to add the database so here is the code I have so far.
Option Compare Database
Option Explicit
'Public IsPreferredGroomer As Boolean
Public FromDateChanged As Boolean
Public CurrRecord As Double
Public Sub CustomerID_RowSource()
If IsNull(Me![AppointmentDate]) Then
Me![CustomerID].RowSource = "SELECT *" & _
"From qryApptHist" & _
" where (((AppointmentDate) >= [Forms]![frmPaymentHistory]![FromDate]))" & _
" ORDER BY AppointmentDate;"
Else
Me![CustomerID].RowSource = "Select *" & _
"From qryApptHist" & _
" where (((AppointmentDate) = [Forms]![frmPaymentHistory]![FromDate]))" & _
" ORDER BY AppointmentDate;"
End If
Me![CustomerID].Requery
End Sub
Private Sub DateDownButton_Click()
FromDate = DateAdd("d", -1, FromDate)
FromDate_AfterUpdate
End Sub
Private Sub DateUpButton_Click()
FromDate = DateAdd("d", 1, FromDate)
FromDate_AfterUpdate
End Sub
Private Sub Form_Activate()
CustomerID.Requery
Me.Requery
CustomerID_RowSource
Detail.Visible = False
If CurrRecord > 0 Then
Me.Requery
DoCmd.GoToRecord acDataForm, "frmPaymentHistory", acGoTo, CurrRecord
Else
Me.Requery
End If
Detail.Visible = True
End Sub
Private Sub Form_AfterUpdate()
Detail.Visible = False
If CurrRecord > 0 Then
Me.Requery
DoCmd.GoToRecord acDataForm, "frmPaymentHistory", acGoTo, CurrRecord
Else
Me.Requery
End If
Detail.Visible = True
FromDate.SetFocus
End Sub
Private Sub FromDate_AfterUpdate()
FromDate = Format(FromDate, "short date")
Me.Requery
Me.Refresh
CustomerID_RowSource
Me![FromDate].SetFocus
'DoCmd.Hourglass False
End Sub
|