Solved

visual basic search

Posted on 1998-07-14
4
163 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
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
Dalin earned 100 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

705 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

22 Experts available now in Live!

Get 1:1 Help Now