[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

visual basic search

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
vcrawford
Asked:
vcrawford
  • 2
1 Solution
 
DalinCommented:
Try


    strSQL = "SELECT PatName FROM DoctorPatInformation WHERE PatName = " & MySring
0
 
DalinCommented:
You can use:
strSQL = "SELECT PatName FROM DoctorPatInformation WHERE PatName = '" & txtPatNm.Text & "'"
0
 
jjmartinCommented:
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
 
JagarCommented:
Also you need ro do a data1.refresh after you change the RecordSource Property.
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now