Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How do i search two field in a table using the SELECT command

Posted on 2003-02-18
5
Medium Priority
?
154 Views
Last Modified: 2010-05-01
The is the satement i a using in my code but does not work what am i doing wrong

Set rst = dbs.OpenRecordset("SELECT * FROM Table1 where " & State & " = '" & (txtbox1.Text) & "'" And City & " = '" & (txtbox2.Text) & "';")

I am trying to find the content of those two field in my table. I am using VB6
0
Comment
Question by:kennyD
5 Comments
 
LVL 39

Accepted Solution

by:
appari earned 150 total points
ID: 7979692
change

Set rst = dbs.OpenRecordset("SELECT * FROM Table1 where " & State & " = '" & (txtbox1.Text) & "'" And City & " = '" & (txtbox2.Text) & "';")

to

Set rst = dbs.OpenRecordset("SELECT * FROM Table1 where State  = '" & (txtbox1.Text) & "' And City = '" & (txtbox2.Text) & "';")
0
 
LVL 4

Expert Comment

by:Sashi Rachabattula
ID: 7979832
if  "State" is a variable than u have to write what u did
else if "State" is a column name do what appari wrote  
0
 

Author Comment

by:kennyD
ID: 7985550
Still didn't get it to work is there another way
0
 

Expert Comment

by:AHawth
ID: 7985600
Try troubleshooting your SQL statement in the VB Visual Data Manager. It's an add-in that shipped with VB5. I don't know if it's still included with VB6

I believe the criteria strings need to be in single quotes. I can't tell if they are in the above comments.
0
 

Author Comment

by:kennyD
ID: 7990836
Let me try and explain what I am trying to do. I have a table with several fields but I am only interested in three first name, last name and weight. Now on my form I have three test box label First Name, Last Name and Weight. What I am trying to accomplish is that if first name and last name textbox has a name that’s in the table then I would know what the weight of that person is by quarrying the weight field in the table.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

578 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