VBA for search

F

Frank Situmorang

Hello,

I will have a minutes of meeting table as follows:
1. Autonumber
2. Decision number
3. Date
4.Decisions which is a MEMO field.

What is the VBA if we want to use a search by key word. Is there any sample
for this?

Thanks

Frank
 
B

Beetle

Here's what we know so far.

1) you have a table.

2) you want to search for something.

More info perhaps?

Are you working in a form?
Are you trying to search the memo field for certain words?
 
B

Beetle

You could add an unbound text box for searching, then use the
After Update event of the text box to run the code. Something like;

Dim strSQL As String

strSQL = "Select tblMeetings.DecisionNumber, tblMeetings.Date, " &_
"tblMeetings.Decisions From tblMeetings Where " &_
"tblMeetings.Decisions LIKE """ & "*" & Me.txtSearch & "*" & """

currentdb.Execute strSQL, dbFailOnError

Or if your form is based on a query then you could apply a filter like;

Dim strFilter As String

strFilter = "([Decisions] LIKE """ & "*" & Me.txtSearch & "*" & """)"

Me.Filter = strFilter
Me.FilterOn = True

You'll need to modify table, field & control names, adjust for line wrap,
quote placement etc., but this may give you a couple of things to try.

BTW - Access has certain words that are "reserved" (like Date) that should
not be used for field and control names. For a list of these words and why
you should not use them see;

http://allenbrowne.com/AppIssueBadWord.html
 
F

Frank Situmorang

Beetle,

I have tried it, this is my VBA:
Private Sub Textcari_AfterUpdate()
Dim strSQL As String

'but red color font/hang over here:

strSQL = "Select MOM. TGLRPT_ID, MOM. No_KEP, , MOM. Subject " &_ MOM. Notes
From MOM Where " &_
" MOM. Notes LIKE """ & "*" & Me.Textcari & "*" & """
'Font is normal again here:
CurrentDb.Execute strSQL, dbFailOnError
End Sub


Pls. help me what goes wrong on my VBA:

For Your info:

I have the form and subform.

Main form is the Meteeng date table

And sub form linked is Decision number/TGLRPT_ID..and I just search by
unbound Textcari


I appreciate your help
 

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