a rookie with a cause

G

Guest

Here is what I have: A query (named: Query) with one field (named:Search)
with the criteria:

Like "*" & [frmMainpage].[Keyword] & "*"

Mainpage is the form that I am trying to create a user-input keyword search
textbox onto (named: keyword)

I then have the 'keyword' text box After Update expression as:

Private Sub keyword_AfterUpdate()

If Not IsNull(keyword) Then
Me.Filter = "[Search] Like ""*" & keyword & "*"""
Me.FilterOn = True
Else
Me.FilterOn = False
End If

End Sub

Something is not right. I may be mixing this up way too much. I have never
built a database in my life and I am just trying to be able to have the user
enter in a word (that would be found in a string of words in the 'Search'
field) and I cannot figure it out.

Can anyone help me?
 
G

Guest

Hi.

You don't say what the problem is that you are having, but I'll assume it is
that the query is not returning any results. Try changing your Criteria to
this:
Like "*" & [Forms]![frmMainpage].[Keyword] & "*"

Also, make sure that the Keyword control on the form is not named the same
as the field. In other words, if your field is also named Keyword, change
the name of the control to something like txtKeyword (and alter the above
Criteria appropriately).

-Michael
 
J

Jeff L

It would be a lot easier to help you if you stated what the issue is.
"Something is not right" doesn't really help. What is not working
correctly that you are expecting to work?

By the way, Like "*" & [frmMainpage].[Keyword] & "*" should be
Like "*" & Forms![frmMainpage]![Keyword] & "*"
 
G

Guest

I am not too sure what is happening. I know that there is a 'lack of'
something. The query is not running (?). This is what I want to do:

I have a database of 2000 properties. I want the user to be able to search
by keyword (of names associated with the property) in the field 'Search.'
The Search field is a string of words (Brunner Building Old Library)where I
would like the user to be able to enter in any one of those words and the
form would appear. I have created a query of the 'Search' field, it is
titled 'Query.' I am not too sure what I need to do/create/express/etc. to
be able to have a user-input box that would be connected to that particular
field. I know that it is different than a combo box, but I am not so sure
how it is that I can achieve this.

Michael H said:
Hi.

You don't say what the problem is that you are having, but I'll assume it is
that the query is not returning any results. Try changing your Criteria to
this:
Like "*" & [Forms]![frmMainpage].[Keyword] & "*"

Also, make sure that the Keyword control on the form is not named the same
as the field. In other words, if your field is also named Keyword, change
the name of the control to something like txtKeyword (and alter the above
Criteria appropriately).

-Michael


ajwittman said:
Here is what I have: A query (named: Query) with one field (named:Search)
with the criteria:

Like "*" & [frmMainpage].[Keyword] & "*"

Mainpage is the form that I am trying to create a user-input keyword search
textbox onto (named: keyword)

I then have the 'keyword' text box After Update expression as:

Private Sub keyword_AfterUpdate()

If Not IsNull(keyword) Then
Me.Filter = "[Search] Like ""*" & keyword & "*"""
Me.FilterOn = True
Else
Me.FilterOn = False
End If

End Sub

Something is not right. I may be mixing this up way too much. I have never
built a database in my life and I am just trying to be able to have the user
enter in a word (that would be found in a string of words in the 'Search'
field) and I cannot figure it out.

Can anyone help me?
 
G

Guest

I am not too sure what is happening. I know that there is a 'lack of'
something. The query is not running (?). This is what I want to do:

I have a database of 2000 properties. I want the user to be able to search
by keyword (of names associated with the property) in the field 'Search.'
The Search field is a string of words (Brunner Building Old Library)where I
would like the user to be able to enter in any one of those words and the
form would appear. I have created a query of the 'Search' field, it is
titled 'Query.' I am not too sure what I need to do/create/express/etc. to
be able to have a user-input box that would be connected to that particular
field. I know that it is different than a combo box, but I am not so sure
how it is that I can achieve this.


Jeff L said:
It would be a lot easier to help you if you stated what the issue is.
"Something is not right" doesn't really help. What is not working
correctly that you are expecting to work?

By the way, Like "*" & [frmMainpage].[Keyword] & "*" should be
Like "*" & Forms![frmMainpage]![Keyword] & "*"

Here is what I have: A query (named: Query) with one field (named:Search)
with the criteria:

Like "*" & [frmMainpage].[Keyword] & "*"

Mainpage is the form that I am trying to create a user-input keyword search
textbox onto (named: keyword)

I then have the 'keyword' text box After Update expression as:

Private Sub keyword_AfterUpdate()

If Not IsNull(keyword) Then
Me.Filter = "[Search] Like ""*" & keyword & "*"""
Me.FilterOn = True
Else
Me.FilterOn = False
End If

End Sub

Something is not right. I may be mixing this up way too much. I have never
built a database in my life and I am just trying to be able to have the user
enter in a word (that would be found in a string of words in the 'Search'
field) and I cannot figure it out.

Can anyone help me?
 
J

Jeff L

It sounds like you want to be able to enter key words in your text
field then have a list of matches display in the form. Correct?

You need to take out the Like statement in the query itself. Have your
form based on the query. You will need to create the fields that you
want in the form. Now when you enter the key words you will need some
sort of action to filter the form, clicking a command button perhaps.
You will need to build the filter with code.

Dim HoldKeyWords as String, MyFilter as String, Position as integer

If Nz(Me.KeyWord) then
HoldKeyWords = Me.KeyWord 'The textbox name
Position = InStr(HoldKeyWords, " ", 1)
If Position = 0 then
MyFilter = HoldKeyWords
Do while Position > 0
If MyFilter = "" Then
MyFilter = MyFilter & "Search Like '*'" & Left(HoldKeyWords,
Position - 1) & "*' "
Else
MyFilter = MyFilter & "OR Search Like '*'" & Left(HoldKeyWords,
Position - 1) & "*' "
End IF
HoldKeyWords = Mid(HoldKeyWords, Position + 1)
Position = InStr(HoldKeyWords, " ", 1)
Loop
Me.Filter = MyFilter
Me.FilterOn = True
Else
Me.FilterOn = False
End If

Hope that helps!




I am not too sure what is happening. I know that there is a 'lack of'
something. The query is not running (?). This is what I want to do:

I have a database of 2000 properties. I want the user to be able to search
by keyword (of names associated with the property) in the field 'Search.'
The Search field is a string of words (Brunner Building Old Library)where I
would like the user to be able to enter in any one of those words and the
form would appear. I have created a query of the 'Search' field, it is
titled 'Query.' I am not too sure what I need to do/create/express/etc. to
be able to have a user-input box that would be connected to that particular
field. I know that it is different than a combo box, but I am not so sure
how it is that I can achieve this.

Michael H said:
Hi.

You don't say what the problem is that you are having, but I'll assume it is
that the query is not returning any results. Try changing your Criteria to
this:
Like "*" & [Forms]![frmMainpage].[Keyword] & "*"

Also, make sure that the Keyword control on the form is not named the same
as the field. In other words, if your field is also named Keyword, change
the name of the control to something like txtKeyword (and alter the above
Criteria appropriately).

-Michael


ajwittman said:
Here is what I have: A query (named: Query) with one field (named:Search)
with the criteria:

Like "*" & [frmMainpage].[Keyword] & "*"

Mainpage is the form that I am trying to create a user-input keyword search
textbox onto (named: keyword)

I then have the 'keyword' text box After Update expression as:

Private Sub keyword_AfterUpdate()

If Not IsNull(keyword) Then
Me.Filter = "[Search] Like ""*" & keyword & "*"""
Me.FilterOn = True
Else
Me.FilterOn = False
End If

End Sub

Something is not right. I may be mixing this up way too much. I have never
built a database in my life and I am just trying to be able to have the user
enter in a word (that would be found in a string of words in the 'Search'
field) and I cannot figure it out.

Can anyone help me?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top