Search Using SQL

How can I search and display the record in another form? Complete code..please

The user is required to key in the search value in textbox(text1) then press the cmdbutton(cmd1).The result will be displayed in form1.

I wanna do searching using ADODB.
Fieldname = Reference Number
Table = Tender
aidanieAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
schworakCommented:
Two questions then you can have your answer...

1, Are you only returning EXACT matches to the information entered by the user or partial matches too?

Exact: bob only matches bob

Partial: red matches red, fred, redhead or anything with red in it.


2, The input is on form2 and the results are on form1? What type of output are you looking for just a list or what?
0
 
priya_pbkCommented:
Try this:

You should have "2 Forms" and a "Module" in your project, form1 and Form2
In Form1 place a textbox, command button and a ADODC1 control
In Form2 place a datagrid control(I have placed this , you can anyway place Mshflexgrid if you dont want to do any editing)

->In Form1 write the following code:

Private Sub Command1_Click()
  showDetails CInt(Text1)
  Form2.Show
End Sub

->In Form2 (No Code)

->In the Module add a procedure like this:

Public Sub showDetails(id As Integer)

 strQuery = "select * from onlinenews where id=" & id
 Form1.Adodc1.RecordSource = strQuery
 Set Form2.DataGrid1.DataSource = Form1.Adodc1

End Sub


I hope this helps!

-priya



0
 
priya_pbkCommented:
change the below code in the procedure..

>>strQuery = "select * from onlinenews where id=" & id

To..

strQuery = "select * from Tender where ReferenceNumber=" & id

Surely you must have done that, right?

-priya


0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
aidanieAuthor Commented:
priya...i do not have ADODC control.where can i download it?
0
 
priya_pbkCommented:
For exact matches or simlar matches try putting an 2 option button next to the command button

Option1.Caption="Exact Match"
option2.Caption="Similar Matches"

Therefore the changes will be
->In Form1

Private Sub Command1_Click()
Dim MatchCreteria As String
If Option1.Value = True Then
  MatchCreteria = "E"
Else
  MatchCreteria = "L"
End If


Call showDetails((Text1.Text), MatchCreteria)
Form2.Show

End Sub


->The procedure in Module:

Public Sub showDetails(id As Variant, mC As String)

If mC = "E" Then
  strQueryMC = " where ReferenceNumber=" & id
Else
  strQueryMC = " where ReferenceNumber like '" & id & "'"
End If
StrQuery = "select * from Tender " & strQueryMC

Form1.Adodc1.RecordSource = StrQuery
Set Form2.DataGrid1.DataSource = Form1.Adodc1

End Sub

-priya
0
 
priya_pbkCommented:
You don't have to download it. It should with the VB6.

Try opening the project as "VB entereprise Edition Controls". When you choose this  as your project you will normally get all the "ActiveX controls of Microsoft". If I remember it right it is the second last control in your toolbox. Just double click it to place it on your form.

Set the 'ConnectionString' only (that is what you require at least in this application). The other things are set at runtime in our code.

I hope you know to set the connectionstring of ADODC control. Like this for your info:

Click the Adodc1 control on your form and press F4 to invoke the properties of Adodc control. Choose the connectionstring property and browse it to your database, ie ms-sql or access or whatever.

Hope this helps! (and i hope you are using VB6)

-priya

0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
priya_pbkCommented:
If you have already choosen the "Standard Exe project", no problem. Go to Project menu, Click componenets,and choose "Microsoft ASO Data Control 6.0 (OLEDB)"

Any progress in this front!

-priya

0
 
aidanieAuthor Commented:
priya...i do not have ADODC control.where can i download it?
0
 
aidanieAuthor Commented:
priya...i do not have ADODC control.where can i download it?
0
 
aidanieAuthor Commented:
priya...i do not have ADODC control.where can i download it?
0
 
priya_pbkCommented:
aidanie,

Pls don't click the Refresh button of the Browser, instead, click the "ReLoad Question" at the top Right hand corner.

Did'nt you get the earlier posts, mentioning that downloading is not required, and it comes with VB6.

How far have you succeeded in implementing the above suggestions, Do let me know abt it and DON'T hit the refresh button, please!!

-priya
0
 
priya_pbkCommented:
Any Progress???

-priya
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.