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!

Parameter Form from Query 1

Status
Not open for further replies.

gRegulator

Technical User
Jul 3, 2003
133
CA
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!
 
When the query is launched the requirements are:
frm_DateParameter must be an open main form
cboStart and cboEnd must hold valid date

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV, thanks for your quick response. How do I make the changes so my frm_DateParameter is an open main form? I dont quite understand.

The way I want this to work is:

When a user attempts to open the query, the form will pop up into which they may submit their parameters. Once the parameters are submitted, the query will open with those date. Im not exactly sure what you mean by open main form.

Thanks for your help :)
 
The usual way is:
The user launch the form, populate the parameters controls and then push a button which Click event procedure launch the parametized query.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
OK, I understand now what you're saying. I was trying to go about this backwards. Its working now.

Thank you so much for your help again today :)

Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top