4 Replies - 6800 Views - Last Post: 21 September 2009 - 05:54 PM Rate Topic: -----

#1 oyong  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 19-July 09

search records in access and pass the searched records to datagrid

Posted 19 July 2009 - 02:35 AM

i would like to search records from access and after searching i would like to pass it to datagrid.
Private Sub cmdsearch_Click()
On Error GoTo err_Handler
   Set Conn = New ADODB.Connection
	Dim rs As New ADODB.Recordset
	Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\newd\CebuYachtClub.mdb;Persist Security Info=False"
	Conn.Open
	rs.Open "Select * From yati where Registration_Number=txtsregnumber.text", Conn, adOpenDynamic, adLockOptimistic
	
	With rs
	   .AddNew
	   
		!Registration_Number = txtrnumber
		!Vessel_Name = txtvname.Text
		!Vessel_Owner = txtvowner.Text
		!Month_Of_Docking = txtmonth.Text
		!Year_Of_Docking = txtyear.Text
		!Day_Of_Docking = txtday.Text
		!LOA = txtloa.Text
		!Beam = txtbeam.Text
		!Hull_Type = txthtype.Text
		!Keel_Draft = txtkdraft.Text
		!Air_Draft = txtadraft.Text
		!Engine = txtengine.Text
		!Port_Of_Origin = txtporigin.Text
		!Distination = txtdistination.Text
		!Lenght_Of_Stay = txtlstay.Text
		!Purpose_Of_Visit = txtpvisit.Text
		!Contact_Number = txtcnumber.Text
		!Email_Address = txtemailadd.Text
		!Port_Of_Registry = txtpregistry.Text
	 .Update
	   MsgBox "Data Found"
		 
	End With
	
	
	rs.Close
	Set rs = Nothing
	 adodcsearch.Refresh
	 dtgrdsearch.Refresh
Exit_Err:
	Exit Sub
err_Handler:
	 MsgBox "No records found", vbExclamation
	Resume Exit_Err
End Sub



Mod Edit: Please use code tags when posting your code. Code tags are used like so => :code:

Thanks,
PsychoCoder :)

This post has been edited by PsychoCoder: 19 July 2009 - 08:52 AM


Is This A Good Question/Topic? 0
  • +

Replies To: search records in access and pass the searched records to datagrid

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: search records in access and pass the searched records to datagrid

Posted 19 July 2009 - 08:52 AM

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:
  • Post the code you're having problems with
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

Was This Post Helpful? 0
  • +
  • -

#3 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: search records in access and pass the searched records to datagrid

Posted 19 July 2009 - 06:37 PM

i can able to find one correction

if registration no is numeric datatype
rs.Open "Select * From yati where Registration_Number=" & val(txtsregnumber.text), Conn, adOpenDynamic, adLockOptimistic



if registration no is string datatype
rs.Open "Select * From yati where Registration_Number='" & txtsregnumber.text &"' ", Conn, adOpenDynamic, adLockOptimistic




other than this error you should mention it
Was This Post Helpful? 0
  • +
  • -

#4 rajaganeshh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-September 09

Re: search records in access and pass the searched records to datagrid

Posted 21 September 2009 - 12:56 AM

I am always having the Msg like No Record Found...

Attached image(s)

  • Attached Image

This post has been edited by rajaganeshh: 21 September 2009 - 01:19 AM

Was This Post Helpful? 0
  • +
  • -

#5 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: search records in access and pass the searched records to datagrid

Posted 21 September 2009 - 05:54 PM

where is your code
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1