Solved

microsoft access question

Posted on 2016-10-07
8
44 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
Comment Utility
Use the OnClick Event of your button to run your Macro as shown below.
Capture1
ET
0
 

Author Comment

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

Author Comment

by:Hiroyuki Tamura
Comment Utility
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
 
LVL 19

Accepted Solution

by:
Eric Sherman earned 500 total points
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

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

Author Closing Comment

by:Hiroyuki Tamura
Comment Utility
thank you
0
 
LVL 19

Expert Comment

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

ET
0
 
LVL 19

Expert Comment

by:Eric Sherman
Comment Utility
Try this for your SELECT statement ...

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


ET
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

728 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now