hello,
i want to find record with number field and text field.

please help me

Hello pranav,

you are providing very poor information,

with this people can't help you without properly understanding your problem/requirement,

I am answering with my assumption
Assumption:
You have a Recordset named "RS"
The Search text is in the string variable "SrchText"
The Searchnumber is in the integer variable "SrchNumt"
and the record set has 3 field
1.RecordID
2.Name(srchText)
3.RegNumber(srchNum)

then follow the code to find the record

rs.movefirst
for i=0 to rs.recordcount-1
if strcomp(rs!Name,srchtext,vbTextcompare)=0 and strcomp(rs!RegNumber,srchnum,vbTextcompare)=0 then
msgbox "Record found  RecoedId: " & rs!RecordID,Vbinformation
end if 
rs.movenext
next

i hope this code will help you,

with regards
Venkatramasamy SN

hello venkatramasamy,

first of thnx for reply and
sorry for poor information.

i m generating form for receipt for the organisation. which covers filds like
RecptNo, Date, PartyName, Type of Income, Cash,Cheque etc

on the base of your coding i found the record but
as n when i click ok button. it shows all fields blank no data in any field
so, still i found problem. please try to help me. following is the coding

Private Sub cmdFind_Click()
rn = InputBox("Enter Receipt No", "Find")
'MsgBox (rn)

Adodc1.Recordset.MoveFirst
For j = 0 To Adodc1.Recordset.RecordCount - 1
If StrComp(Adodc1.Recordset.Fields("recno"), rn, vbTextCompare) = 0 Then
MsgBox "record found", vbInformation + vbOKOnly, "Record"
End If
Adodc1.Recordset.MoveNext
Next

End Sub

waiting for solution

HI Pranav,

The problem is very simple and basic,
in your code you compared the data good,where yoiu assunged the data to dispaly..?
that is the problem
controls:
TxtRecpt-Textbox
Txtdate-Textbox
TxtPname-textBOx
cbmIncome-Combobox

assign the data to an control to distaple like datagrid or text box etc..
for example...

Private Sub form_load()
cbmIncome.additem("Cash")
cbmIncome.additem("Cheque")
end sub
Private Sub cmdFind_Click()
rn = InputBox("Enter Receipt No", "Find")
'MsgBox (rn)
Adodc1.Recordset.MoveFirst
For j = 0 To Adodc1.Recordset.RecordCount - 1
If StrComp(Adodc1.Recordset.Fields("recno"), rn, vbTextCompare) = 0 Then
     TxtRecpt.text=Adodc1.Recordset.Fields("recno")
    Txtdate.text=Adodc1.Recordset.Fields("date")
    TxtPname.text=Adodc1.Recordset.Fields("Partyname")
    cbmIncome.text=Adodc1.Recordset.Fields("IncomeType")
else
    MsgBox "No records available with the Enteres receipt no", vbInformation + vbOKOnly, "Record"

End If
Adodc1.Recordset.MoveNext
Next
end sub

hope this code will help you,

With regards
Venkatramasamy SN

thnx for suggestion.

i made a little bit change

following code is working properly

Private Sub cmdFind_Click()
rn = InputBox("Enter Receipt No", "Find")
'MsgBox (rn)

Adodc1.Recordset.MoveFirst
For j = 0 To Adodc1.Recordset.RecordCount - 1
If StrComp(Adodc1.Recordset.Fields("recno"), rn, vbTextCompare) = 0 Then
MsgBox "record found", vbInformation + vbOKOnly, "Record"
Exit For
End If
Adodc1.Recordset.MoveNext
Next

If Adodc1.Recordset.EOF = True Then
Adodc1.Recordset.MovePrevious
End If

If Not StrComp(Adodc1.Recordset.Fields("recno"), rn, vbTextCompare) = 0 Then
MsgBox "Receipt No. not found", vbInformation + vbOKOnly, "Record"
End If

End Sub

is there any mistake then tell me??

againg thnx for this help.
- pranav

hi pranav,

are you tried my code or not,

the code you are furnished is correct,

i'll give one more suggestion
in my code in the "else" part of the "IF" condition use an boolean variable

The modified code will be like this...

Private Sub form_load()
cbmIncome.additem("Cash")
cbmIncome.additem("Cheque")
end sub
Private Sub cmdFind_Click()
dim Rfound as boolean
Rfound=false
rn = InputBox("Enter Receipt No", "Find")
'MsgBox (rn)
Adodc1.Recordset.MoveFirst
For j = 0 To Adodc1.Recordset.RecordCount - 1
If StrComp(Adodc1.Recordset.Fields("recno"), rn, vbTextCompare) = 0 Then
    TxtRecpt.text=Adodc1.Recordset.Fields("recno")
    Txtdate.text=Adodc1.Recordset.Fields("date")
    TxtPname.text=Adodc1.Recordset.Fields("Partyname")
    cbmIncome.text=Adodc1.Recordset.Fields("IncomeType")
    Rfound=true
    Exit for
else
    Rfound=false
End If
Adodc1.Recordset.MoveNext
Next

if Rfound=false then
    msgbox "ReceiptNumber Not found", Vbinformation
end if

end sub

reply me about the status

With regards
Venkatramasamy SN

hi,

ya that one is also working.
but as and when record found, it shows all the fields with the proper data. no need to transfer to textbox or to combobox or other objects. its coming automatically.

boolean concept is againg proper with else if. that is also working

againg thnx for such valuable help. bcaz i m making this form and other part of softr not for professional purpose but for the devotional purpose. i m making one software on account base for the Temple. Receipt and Expense for the Temple

so thnx for the help

Hi Pranav,
Good work,

i appricite your work commitment with a temple with service mind

keep on working on those things,

All the best

with regards
Venkatramasamy

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.