VBA for search

  • Thread starter Thread starter Frank Situmorang
  • Start date Start date
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
 
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?
 
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
 
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
 
Back
Top