One Important Question

djrock

Registered User.
Local time
Today, 15:57
Joined
Jan 12, 2003
Messages
15
Does any know are you able to within a form to search your table?

I want to know this to see if its wasting my time searching on how to do it
 
Yes, there are ways to search the table that you have bound to the form. There are also ways to search tables that are not bound to the form, but you'd need to use some ADO to accomplish it.

Unfortunately, as I have to leave right now, I don't have time to give a full "how to." But you should be able to search the archives of this bulletin board and find what you need.

Look for "searching recordsets" or something of that nature.
 
djrock,

You can put an unbound text box on your form.
In the AfterUpdate event you can ...

Me.RecordSource =
"select * " & _
"From MyTable " & _
"Where MyKey = '" & Me.MyTextBox & "'"

Me.Requery
Me.Refresh

Wayne
 
and how where do i use that code because i don't really know very much about the programming side of access.

Me.RecordSource =
"select * " & _
"From MyTable " & _
"Where MyKey = '" & Me.MyTextBox & "'"

Me.Requery
Me.Refresh
 
djrock,

Put it in the AfterUpdate event for the unbound text box.

Right-click on it, choose properties, then go to the event
tab.

Wayne
 
Me.RecordSource =
"select * " & _
"From MyTable " & _
"Where MyKey = '" & Me.MyTextBox & "'"

Me.Requery
Me.Refresh

what do you fill in this code i entered it in and its all red and the complier brought up an error

I am not an expert at visual basic so iam stuck
 
Last edited:
First of all you have to start the SQL statement on the same line as your me.recordsource=
 
sorry i still don't understand you in the code what goes where like where do i specify what table/query i want it to goto and what field its meant to search?

Me.RecordSource = is something meant to go here?
"select * " & _ what about here?
"From MyTable " & _ here?
"Where MyKey = '" & Me.MyTextBox & "'" here?

Me.Requery
Me.Refresh
 
djrock,

Me.RecordSource = "select * " & _
"From MyTable " & _
"Where MyKey = '" & Me.MyTextBox & "'"

Me.Requery
Me.Refresh

I just formatted it for readability, you have to get used to the
syntax. The & is the concatenation symbol and the _ is
used to mean continued on next line. If MyTextBox had an
X in it the end result would be (after Access parses it):

Me.RecordSource = "Select * From MyTable Where MyKey = 'X'

Wayne
 
Me.RecordSource = "Select * From query2 Where EnterLowestAmount = 'X' "

I can't get this code to work i edited it but what happens when i enter a number in the box on the form e.g. "10" a dialog box pop's up with the title "Enter Parameter Value" it pops up 2-3 times then enter a value hit ok it disappers but the form is blank i have prices over 10 pounds.

table called :accomodation
query the table accommodation :query2 in the critera it has >=[enterlowestamount]

even with a new query without no critera its still the same
 
djrock,

You don't need a query.

' ***********************************
Me.RecordSource = "select * " & _
"From MyTable " & _
"Where MyKey = '" & Me.MyTextBox & "'"

Me.Requery
Me.Refresh
' ***********************************


Just Change MyTable to the name of your Table
MyKey to the Table's field that matches your TextBox
Me.MyTextBox to the name of your textbox.

Now, you could use a query. That query would be the form's
recordsource. It would have, in the criteria field, for the field
that matches your textbox, =Forms![YourForm]!YourTextBox

Either one way or the other, not both!

Wayne
 
A error comes up "run time error '3075' syntax error (missing operator) in query experestion 'price of accomodation = '10"

Me.RecordSource = "select * " & _
"From accomodation " & _
"Where price of accomodation = '" & Me.Text100 & "'"
 
djrock,

Me.RecordSource = "select * " & _
"From accomodation " & _
"Where price of accomodation = '" & Me.Text100 & "'"

What is price of accomodation?

[price of accomodation]?

SQL is expecting a one word column name. After it parses
"price" it is expecting a relational operator (=, <, >, <>)
and it encounters "of".

Wayne
 
"price of accomodation" is my field name in my table i will be searching
 
djrock,

You'll have to put the square brackets around it as in the
previous post.

Generally its a good idea not to put spaces or special characters
in field names.

Wayne
 
its now coming up with a run time error '2001' 'You cancelled the previous operation'
 
Last edited:

Users who are viewing this thread

Back
Top Bottom