Solved

microsoft access question

Posted on 2016-10-07
8
60 Views
Last Modified: 2016-10-07
how do i  create a button on form to search by macro?
0
Comment
Question by:Tony T
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Tony T
ID: 41833842
thank you.
I need a macro script for searching
Snap1293.jpg
0
 

Author Comment

by:Tony T
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
Webinar: Choosing a MySQL HA Solution

Join Percona’s Principal Technical Services Engineer, Marcos Albe as he presents Choosing a MySQL High Availability Solution on Thursday, June 29, 2017 at 10:00 am PDT / 2:00 pm EDT (UTC-7).

 
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:Tony T
ID: 41834074
thank you.
what should i put here?
Snap1297.jpg
0
 

Author Closing Comment

by:Tony T
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

729 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