Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Form for record

Status
Not open for further replies.

gasx

Technical User
Feb 28, 2003
22
US
use this code below to find record on the form. is working fine without error. my problem when it show me msgbox "record found" it doesn't call my client record on my client inforamtion form. i think i need to add more code to pull my client record if it show that the record exist.

Private Sub Command1_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\jsdegard\Desktop\PieceWeight.mdb;User Id=admin;Password=;"

Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "Select * From tblmain Where partno = '" & Text0.Text & "'", cn, adOpenKeyset, adLockOptimistic, -1

If rs.BOF And rs.EOF Then
MsgBox "No records match the current criteria!", vbCritical
Else
MsgBox "Record Found!", vbInformation
End If
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
End Sub
 
Something like:
Code:
If rs.BOF And rs.EOF Then
MsgBox "No records match the current criteria!", vbCritical
Else
MsgBox "Record Found!", vbInformation
[red]Text1.Text = rs!YourField[/red]
End If
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
End Sub
Hope this helps

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
your explainantion makes no sence. your code will only show a message box. what do you want it to do?
 
i mean when it show a message box," record found " hit enter it pull the record for that client on client form.

 
Something like I posted in my post???

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
How do you want it displayed. In a grid or a simple textbox like HarleyQuinn has posted

just note that if you have a space in your field name then you will need to do the following RS("Your Field Name") and not RS!YourFieldName
 
Agreement with AEtherson, how would you like it displayed?

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top