Solved

microsoft access question

Posted on 2016-10-07
8
53 Views
Last Modified: 2016-10-07
how do i  create a button on form to search by macro?
0
Comment
Question by:Hiroyuki Tamura
  • 4
  • 4
8 Comments
 
LVL 19

Expert Comment

by:Eric Sherman
ID: 41833806
Use the OnClick Event of your button to run your Macro as shown below.
Capture1
ET
0
 

Author Comment

by:Hiroyuki Tamura
ID: 41833842
thank you.
I need a macro script for searching
Snap1293.jpg
0
 

Author Comment

by:Hiroyuki Tamura
ID: 41833985
I'm getting following error
Private Sub Command5_Click()
Dim strsearch As String
Dim Task As String
'Check if a keyword entered or not
If IsNull(Me.txtSearch) Or Me.txtSearch = "" Then
   MsgBox "Please type in your search keyword.", vbOKOnly, "Keyword Needed"
   Me.txtSearch.BackColor = vbYellow
   Me.txtSearch.SetFocus
Else
    strsearch = Me.txtSearch.Value
    Task = "SELECT * FROM Copy and Paste WHERE ((Comment Like ""*" & strsearch & "*""))"
   Me.Comment = Task
   Me.txtSearch.BackColor = vbWhite
End If
End Sub

Open in new window

Snap1295.jpg
Snap1296.jpg
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 19

Accepted Solution

by:
Eric Sherman earned 500 total points
ID: 41834025
I think your SQL is not correct ... The Select statement you look like this:

Task = "SELECT * FROM YourTableNameHere WHERE ((YourFieldNameHere Like ""*" & strsearch & "*""))"
Me.RecordSource = Task

ET
0
 

Author Comment

by:Hiroyuki Tamura
ID: 41834074
thank you.
what should i put here?
Snap1297.jpg
0
 

Author Closing Comment

by:Hiroyuki Tamura
ID: 41834100
thank you
0
 
LVL 19

Expert Comment

by:Eric Sherman
ID: 41834143
Post the contents of your string variable Task after it has been populated.

ET
0
 
LVL 19

Expert Comment

by:Eric Sherman
ID: 41834190
Try this for your SELECT statement ...

Task = "SELECT * FROM TableName WHERE FieldName LIKE '*" & strSearch & "*';"


ET
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question