Then open the form with the Where Condition set same as the filter in my
previous post. Eg.
DoCmd.OpenForm "tblPropellant Query",,,"ITD between " & Nz(MinDTI.Value, 0)
& " and " & Nz(MaxDTI.Value, 0)
The above line should all be on one line. Watch for newsreader wrap
This time the assumptions here are:
* I assume the two text boxes are on the form that is opening
"tblPropellant Query" form
* I assume the name of the form you are opening is "tblPropellant Query"
I still think you should stop writing code for a day or two and start
looking at solutions written by others and reading books. In the end you
will be far more productive. Before you knew how to read it would have been
fruitless for your parents to want you the write the next great novel. Try
to master the basics first.
Also try to use names that are more appropriate for the kinds of objects you
are working with. "tblPropellant Query" could be the worst name I have seen
for a form. As long as you are gonna' go into study and learn mode, spend a
few minutes at
http://www.xoc.net/standards/rvbanc.asp to get a solid
foundation on Naming Conventions.
Ron W
Ron,
sorry about being light on the info, I actualy have the text boxes in a
search form that I want to use to open the data form for the search
criteria.
so would I change Me.Filter to the form I want to opens Name.Filter?
Also I am getting an object required runtime error for the first line of
code Me.Filter=...
any ideas?
If there is any information that would make this easier for you just tell
me
where to find it and I will send it to you, I am still fairly new at this.
Thanks,
James
:
James
You are kinda' light on the info provided so I have no choice but to
make
some assumptions.
* I assume the form is a continuous form
* I assume the two text boxes are in the forms header and are not
bound
to anything
* I assume there is a button named cmdFilter also in the forms
header
* I assume the that ITD is some kind of a number
Then in the code behind the form in the click event of the cmdFilter
button
add the following.
Private Sub cmdFilter_Click()
' Purpose Filter the records to include only the records
' whose ITD value is between MinDTI and MaxDTI
Me.filter = "ITD between " & Nz(MinDTI.Value, 0) _
& " and " & Nz(MaxDTI.Value, 0)
Me.FilterOn = True
End Sub
User enters some values in the min and max text boxes, pushes the
button,
and the form filters OUT all of the records that are not between the min
and
max values. If either text box is null then the Nz() function supplies
a 0
to the filter. If the user enters a non numeric value it will generate
an
error, so you need to insure the users only enter values that are
appropriate for the data you are manipulating before you apply the
filter.
If any of my assumptions are not correct then this solution is a non
solution, sorry:-(
Watch for Newsreader wrap and good luck with your project.
Ron W
Ok, here is some data
The form name is tblPropellant Query, which is the same name as the
query
it
was made from.
The Field name to search is ITD,
and the data entry field names are MinDTI and MaxDTI,
and so there is no confusion the field names are supposed to be the
flip
of
ITD
if you need any other data just ask
Thanks,
James
:
James
Sounds like a parameterized query to me.
SELECT foo, bar
FROM FooBar
WHERE foo Between [Enter Min foo] And [Enter Max Foo]
ORDER BY foo, bar
If you can supply the DDL and some test data along with a good
specification, I will be happy write the code for you.
Ron W
Hi again,
I know I must sound like a broken record but I still have one
question
How can I search a field for a range of numbers. Now I know most
of
you
will want me to use queries but my boss wants it in VB so I have
little
choice. Does anyone know a code that will work. preferably one
that
will
require the user to enter only one number, but I am ok with the
user
inputing
the range ie from # to #.
Thanks!
James