DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   Adding a search function (http://www.daniweb.com/forums/thread164819.html)

brothertse2008 Dec 29th, 2008 5:41 pm
Adding a search function
 
OK im new to this so bear with me. I need to add a search function to my project. I need to input a value into a textbox, click a submit button and a screen needs to appear with the results

Ive got a the following code but i get errors :
Private Sub cmdsubmit_click()

'Declare local variables

Dim store As String

store = txtsearch.Text
mycriteria = "title =" & "'" & store & "'"
Data1.Recordset.FindFirst.store

If Data1.Recordset.NoMatch Then
    Data1.Recordset.MoveFirst
    MsgBox "Record not found", vbExclamation, "Error"


End If

End Sub
what am i missing here. The errri comes up on the "Data1.Recordset.FindFirst.store" line

Comatose Dec 29th, 2008 8:46 pm
Re: Adding a search function
 
I'm pretty sure that you can't use a variable name as a property of an object..... you could try this instead:
Data1.Recordset.FindFirst(store) ' might work

brothertse2008 Dec 30th, 2008 3:59 pm
Re: Adding a search function
 
didnt work

ryan311 Dec 30th, 2008 7:27 pm
Re: Adding a search function
 
what entity you are searching in you access?

debasisdas Dec 31st, 2008 1:36 am
Re: Adding a search function
 
if using ADO that can be done by using SQL queries using LIKE search.

brothertse2008 Dec 31st, 2008 2:27 pm
Re: Adding a search function
 
I have to use access due to college criteria. Im searching the "tittle" in the database.
usualy i say :

data1.recordset.findfirst.store

this problem also occurs when attempting to add a record

ryan311 Dec 31st, 2008 11:53 pm
Re: Adding a search function
 
is the title is entity if entity use this


data1.recordsource = ("Select * from name_of_the_table where title - '" & store 7 "'")


regards
Ryan Riel

brothertse2008 Jan 2nd, 2009 12:03 pm
Re: Adding a search function
 
this is driving me mental lol. My code is as follows but cant get it working.Do i need to have a hide/show function also to display the results?

Private Sub cmdsubmit_click()

'Declare local variables
Dim store As String

'Get the search information

store = txtsearch.Text
mycriteria = "title =" & "'" & store & "'"
Data1.Recordset.FindFirst mycriteria

If Data1.Recordset.NoMatch Then
Data1.Recordset.MoveFirst
MsgBox "Record not found", vbExclamation, "Error"
End If


End Sub

ryan311 Jan 3rd, 2009 10:12 am
Re: Adding a search function
 
store = txtsearch.Text
mycriteria = "title =" & "'" & store & "'"
Data1.Recordset.FindFirst mycriteria
data1.recordset.movenext


All times are GMT -4. The time now is 4:23 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC