Adding a search function

Reply

Join Date: Dec 2008
Posts: 8
Reputation: brothertse2008 is an unknown quantity at this point 
Solved Threads: 0
brothertse2008 brothertse2008 is offline Offline
Newbie Poster

Adding a search function

 
0
  #1
Dec 29th, 2008
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 :
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub cmdsubmit_click()
  2.  
  3. 'Declare local variables
  4.  
  5. Dim store As String
  6.  
  7. store = txtsearch.Text
  8. mycriteria = "title =" & "'" & store & "'"
  9. Data1.Recordset.FindFirst.store
  10.  
  11. If Data1.Recordset.NoMatch Then
  12. Data1.Recordset.MoveFirst
  13. MsgBox "Record not found", vbExclamation, "Error"
  14.  
  15.  
  16. End If
  17.  
  18. End Sub
what am i missing here. The errri comes up on the "Data1.Recordset.FindFirst.store" line
Last edited by Ancient Dragon; Jan 5th, 2009 at 3:19 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Adding a search function

 
0
  #2
Dec 29th, 2008
I'm pretty sure that you can't use a variable name as a property of an object..... you could try this instead:
visualbasic Syntax (Toggle Plain Text)
  1. Data1.Recordset.FindFirst(store) ' might work
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 8
Reputation: brothertse2008 is an unknown quantity at this point 
Solved Threads: 0
brothertse2008 brothertse2008 is offline Offline
Newbie Poster

Re: Adding a search function

 
0
  #3
Dec 30th, 2008
didnt work
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 161
Reputation: ryan311 has a little shameless behaviour in the past 
Solved Threads: 1
ryan311 ryan311 is offline Offline
Junior Poster

Re: Adding a search function

 
0
  #4
Dec 30th, 2008
what entity you are searching in you access?
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,068
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 123
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: Adding a search function

 
0
  #5
Dec 31st, 2008
if using ADO that can be done by using SQL queries using LIKE search.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 8
Reputation: brothertse2008 is an unknown quantity at this point 
Solved Threads: 0
brothertse2008 brothertse2008 is offline Offline
Newbie Poster

Re: Adding a search function

 
0
  #6
Dec 31st, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 161
Reputation: ryan311 has a little shameless behaviour in the past 
Solved Threads: 1
ryan311 ryan311 is offline Offline
Junior Poster

Re: Adding a search function

 
0
  #7
Dec 31st, 2008
is the title is entity if entity use this


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


regards
Ryan Riel
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 8
Reputation: brothertse2008 is an unknown quantity at this point 
Solved Threads: 0
brothertse2008 brothertse2008 is offline Offline
Newbie Poster

Re: Adding a search function

 
0
  #8
Jan 2nd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 161
Reputation: ryan311 has a little shameless behaviour in the past 
Solved Threads: 1
ryan311 ryan311 is offline Offline
Junior Poster

Re: Adding a search function

 
0
  #9
Jan 3rd, 2009
store = txtsearch.Text
mycriteria = "title =" & "'" & store & "'"
Data1.Recordset.FindFirst mycriteria
data1.recordset.movenext
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC