By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,162 Members | 999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,162 IT Pros & Developers. It's quick & easy.

mapping of query result to access forms

P: 1
I want to create a form which is linked to a table.I want to have an extra field "search" so that I can find the desired person...the search textfield will
have a corresponding button in it so that it can run a query which will show the result in the respective form fields related to the search.

Eg.

Form has 2 fields name ,id
in serch i want to enter the corresponding name to get the employee id...
I want the query to be specific like'abhishek' names may be many so it should show all the enteries related to the name 'abhishek'
Dec 7 '07 #1
Share this Question
Share on Google+
1 Reply


puppydogbuddy
Expert 100+
P: 1,923
I want to create a form which is linked to a table.I want to have an extra field "search" so that I can find the desired person...the search textfield will
have a corresponding button in it so that it can run a query which will show the result in the respective form fields related to the search.

Eg.

Form has 2 fields name ,id
in serch i want to enter the corresponding name to get the employee id...
I want the query to be specific like'abhishek' names may be many so it should show all the enteries related to the name 'abhishek'
Try the code below. Don't forget to replace object names used for illustrative purposes with the actual names of the objects in your application.

' Chr(42) is ASCii for the wildcard symbol *
' Assumes that Name and ID controls on the form are bound to the fields in the table
' assumes that the search textbox (txtSearch) on the form is unbound

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnSearch_Click()      'search button
  2. Dim strSql As String
  3.  
  4. strSql = "Select [Name], [ID] From YourTable Where [Name] Like '" & Chr(42) & Me!txtSearch & Chr(42) & "'"
  5.  
  6. Me.RecordSource = strSql
  7.  
  8. End Sub
Dec 8 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.