Searching for records between two dates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Ok, I have two text boxes two enter short dates into, a button click opens a
form which displays the results of a query that does the date comparison.

When I click the button access then asks me to put the dates in, even though
they're already in the textboxes. If I enter the dates into the prompts then
the results are correct. What I'm, wondering is why the query can't seem to
read the values from the form directly. Is there something extra that needs
to be done with dates?
 
What have you got in the query as parameters? If it's Forms!<name of
form>!<name of control> (where <name of form> and <name of control> are
replaced with the appropriate values), it should work.
 
Actually, it's kind of working now. Without my changing it. Now, if I don't
enter anything into the prompts, it brings up the correct results. But it's
still prompting me. Can I get rid of the prompts?
 
Actually, it's kind of working now. Without my changing it. Now, if I don't
enter anything into the prompts, it brings up the correct results. But it's
still prompting me. Can I get rid of the prompts?

A couple of possibilities:

- Is the form open when you try to run the query? It should be; the
query won't open the form for you.
- Might you have misspelled the name of the form in the criterion?
- It may be worthwhile to put the two parameters into the Query's
Parameters collection: right mouseclick the grey background of the
tables in the query grid, select Parameters, and copy and paste the
criteria (they must match EXACTLY) into the Parameters column. Specify
Date/Time in the second column.
 
Thankyou, I had a typo in my parameter specs. Fixed now. Thanks very much for
your help. Now if you could tell me how to get a cancel button going (above)
then I'll love you forever.
 
Thankyou, I had a typo in my parameter specs. Fixed now. Thanks very much for
your help. Now if you could tell me how to get a cancel button going (above)
then I'll love you forever.

I'm not altogether certain that your offered incentive is the best
choice but...

a Cancel button with code such as

Private Sub cmdCancel_Click()
Dim iAns As Integer
iAns = MsgBox("This will cancel the entry and erase your input. OK?" _
, vbYesNo)
If iAns = vbYes Then
Me.Undo
End If
End Sub

will let the user cancel a record being added (of course, hitting
<Esc> twice will do the same).

Since I couldn't find a post in this thread involving a cancel button,
I'm not sure this is what you want!
 
Back
Top