Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

visual basic search

Posted on 1998-07-14
4
Medium Priority
?
180 Views
Last Modified: 2013-11-25
What SQL statement can help me with this program to search for a name I type in a text (txtPatNm) and put a check mark in the appropriate box either patient found or not found.  My program below is not working? Why? My database table is called DoctorPatInformation and the field with the patient Name is called PatName.  I linked the database with the form by using the data button and also the text with the PatName field.

MyString = txtPatNm.Text
strSQL = "SELECT PatName, FROM DoctorPatInformation WHERE PatName = MySring"
Data1.RecordSource = strSQL
 
 If strSQL = MyString Then
 chkPatFound.Value = 1
 
 Else
 chkPatNotFound.Value = 1
 End If
 'Data1.RecordSource = "SELECT * FROM DoctorPatInformation "
 'Data1.Refresh
End Sub

0
Comment
Question by:vcrawford
[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
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
Dalin earned 200 total points
ID: 1465734
Try


    strSQL = "SELECT PatName FROM DoctorPatInformation WHERE PatName = " & MySring
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1465735
You can use:
strSQL = "SELECT PatName FROM DoctorPatInformation WHERE PatName = '" & txtPatNm.Text & "'"
0
 
LVL 3

Expert Comment

by:jjmartin
ID: 1465736
It looks to me as if the problem is also in the compare statement "If strSQL = MyString" strSQL is set to your SQL statement, and MyString is set to whatever is typed in the textbox.  Nothing is returned to the control until the data1.refresh.

0
 
LVL 2

Expert Comment

by:Jagar
ID: 1465737
Also you need ro do a data1.refresh after you change the RecordSource Property.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Suggested Courses

722 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