Solved

visual basic search

Posted on 1998-07-14
4
178 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 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month4 days, 13 hours left to enroll

636 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