aidanie
asked on
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
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
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
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
End Sub
I hope this helps!
-priya
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
>>strQuery = "select * from onlinenews where id=" & id
To..
strQuery = "select * from Tender where ReferenceNumber=" & id
Surely you must have done that, right?
-priya
ASKER
priya...i do not have ADODC control.where can i download it?
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
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
End Sub
-priya
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
Any progress in this front!
-priya
ASKER
priya...i do not have ADODC control.where can i download it?
ASKER
priya...i do not have ADODC control.where can i download it?
ASKER
priya...i do not have ADODC control.where can i download it?
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
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
Any Progress???
-priya
-priya
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?