[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

using SQL with OR ??

Posted on 1999-01-16
9
Medium Priority
?
196 Views
Last Modified: 2010-05-03
i would like to make a statement like this
sSql = "SELECT * FROM Makpel" & _
       "WHERE nama = '" & Text1.Text & "' &" _
       "OR namabapa = '"&Text4.Text&"' " & _
       "ORDER BY nama"
that is if the record match any text value the record will be display
0
Comment
Question by:pohkheng1
[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
  • 3
  • 3
  • 3
9 Comments
 

Author Comment

by:pohkheng1
ID: 1468947
Adjusted points to 100
0
 
LVL 3

Accepted Solution

by:
a111a111a111 earned 300 total points
ID: 1468948
sSql = "SELECT * FROM Makpel WHERE Name = Text1.Text OR nama = Text4.text ORDER BY nama"
0
 
LVL 7

Expert Comment

by:Dedushka
ID: 1468949
Hi, pohkheng1!

Assume, Text1 contains "xxxxx" and Text4 contains "yyyyy". The final SQL string, that will pass to DBMS should be:
---------
SELECT * FROM Makpel WHERE nama = "xxxxx" OR namabapa = "yyyyy" ORDER BY nama;
---------

To create this SQL use following code:

sSql = "SELECT * FROM Makpel" & _
       " WHERE nama = " & _     'space before WHERE
       Chr(34) & Text1.Text & Chr(34) & _
       " OR namabapa = " & _    'space before OR
       Chr(34) & Text4.Text & Chr(34) & _
       " ORDER BY nama;"        'space before ORDER

Cheers,
Dedushka
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:a111a111a111
ID: 1468950
Correction:

Sql = "SELECT * FROM Makpel" & _
           "WHERE nama = '" & & CStr(Text1.Text) & "' &" _
           "OR namabapa = '" & & CStr(Text4.Text) &"' " & _
           "ORDER BY nama"

the key is
"WHERE NNNN = " & CStr(text1.text) & "
0
 

Author Comment

by:pohkheng1
ID: 1468951
Dedushka sql seems to have error coming out
it run rime error 3061
it say to few parameters. Expected 1
solve this and u gain the point
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1468952
Hi again,
your Field nama or namabapa as not spell correct or CASE sensitive.

OR your TABLE is not spell correctly: is it Makpel?


The help on this error say:
This parameter query requires the specified number of parameters, which you didn't supply. Provide the expected number of parameters, and run the query again.
In some cases, this message is generated when unknown field names or expressions are interpreted as query parameters. Be sure to enclose field names containing spaces or punctuation with square brackets [ ].  

So check your database for the correct table AND field names!

0
 
LVL 7

Expert Comment

by:Dedushka
ID: 1468953
pohkheng1,
remove comments from code and use it, i.e.:
sSql = "SELECT * FROM Makpel" & _
       " WHERE nama = " & _
       Chr(34) & Text1.Text & Chr(34) & _
       " OR namabapa = " & _
       Chr(34) & Text4.Text & Chr(34) & _
       " ORDER BY nama;"

Good luck,
Dedushka
0
 

Author Comment

by:pohkheng1
ID: 1468954
thanks a lot
0
 
LVL 7

Expert Comment

by:Dedushka
ID: 1468955
pohkheng1,
sorry, i don't understand.
You say me "thanks" and give point to a111a111a111?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

656 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