gRegulator
Technical User
Hi everyone,
I have made a query which has two fields that I would like to put parameters on. These two fields are date fields which would allow users to check for records within a certain time frame. I have designed a form (frm_DateParameter) which the user can input these desired dates in fields cboStart and cboEnd. In the query criteria field for the beginning date I have put the following statement: [Forms]![frm_DateParameter]![cboStart]. I dont know what I am missing, but I thought that would be correct. Whenever I try to view my query, the regular parameter box pops up, not my form. Maybe I dont know how to correctly link the two together (frm_DateParameter) and (qry_Prob_DateSelect)? I will paste the code below that I have in my form. Can anyone help me on solving this problem?
Option Compare Database
Option Explicit
Dim cboOriginator As ComboBox
Private Sub cboEnd_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Note which combo box called the calendar
Set cboOriginator = cboEnd
' Unhide the calendar and give it the focus
ocxCalendar.Visible = True
ocxCalendar.SetFocus
' Match calendar date to existing date if present or today's date
If Not IsNull(cboOriginator) Then
ocxCalendar.Value = cboOriginator.Value
Else
ocxCalendar.Value = Date
End If
End Sub
Private Sub cboStart_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Note which combo box called the calendar
Set cboOriginator = cboStart
' Unhide the calendar and give it the focus
ocxCalendar.Visible = True
ocxCalendar.SetFocus
' Match calendar date to existing date if present or today's date
If Not IsNull(cboOriginator) Then
ocxCalendar.Value = cboOriginator.Value
Else
ocxCalendar.Value = Date
End If
End Sub
Private Sub ocxCalendar_Click()
' Copy chosen date from calendar to originating combo box
cboOriginator.Value = ocxCalendar.Value
' Return the focus to the combo box and hide the calendar and
cboOriginator.SetFocus
ocxCalendar.Visible = False
' Empty the variable
Set cboOriginator = Nothing
End Sub
Private Sub cmdCancel_Click()
DoCmd.Close
End Sub
Thanks so much for your help!
I have made a query which has two fields that I would like to put parameters on. These two fields are date fields which would allow users to check for records within a certain time frame. I have designed a form (frm_DateParameter) which the user can input these desired dates in fields cboStart and cboEnd. In the query criteria field for the beginning date I have put the following statement: [Forms]![frm_DateParameter]![cboStart]. I dont know what I am missing, but I thought that would be correct. Whenever I try to view my query, the regular parameter box pops up, not my form. Maybe I dont know how to correctly link the two together (frm_DateParameter) and (qry_Prob_DateSelect)? I will paste the code below that I have in my form. Can anyone help me on solving this problem?
Option Compare Database
Option Explicit
Dim cboOriginator As ComboBox
Private Sub cboEnd_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Note which combo box called the calendar
Set cboOriginator = cboEnd
' Unhide the calendar and give it the focus
ocxCalendar.Visible = True
ocxCalendar.SetFocus
' Match calendar date to existing date if present or today's date
If Not IsNull(cboOriginator) Then
ocxCalendar.Value = cboOriginator.Value
Else
ocxCalendar.Value = Date
End If
End Sub
Private Sub cboStart_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Note which combo box called the calendar
Set cboOriginator = cboStart
' Unhide the calendar and give it the focus
ocxCalendar.Visible = True
ocxCalendar.SetFocus
' Match calendar date to existing date if present or today's date
If Not IsNull(cboOriginator) Then
ocxCalendar.Value = cboOriginator.Value
Else
ocxCalendar.Value = Date
End If
End Sub
Private Sub ocxCalendar_Click()
' Copy chosen date from calendar to originating combo box
cboOriginator.Value = ocxCalendar.Value
' Return the focus to the combo box and hide the calendar and
cboOriginator.SetFocus
ocxCalendar.Visible = False
' Empty the variable
Set cboOriginator = Nothing
End Sub
Private Sub cmdCancel_Click()
DoCmd.Close
End Sub
Thanks so much for your help!