Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Mar 2007
Posts: 24
Reputation: pranavdv is an unknown quantity at this point 
Solved Threads: 0
pranavdv pranavdv is offline Offline
Newbie Poster

Find Record

 
0
  #1
Jan 8th, 2008
hello,
i want to find record with number field and text field.

please help me
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 71
Reputation: venkatramasamy is an unknown quantity at this point 
Solved Threads: 12
venkatramasamy's Avatar
venkatramasamy venkatramasamy is offline Offline
Junior Poster in Training

Re: Find Record

 
0
  #2
Jan 8th, 2008
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
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. rs.movefirst
  2. for i=0 to rs.recordcount-1
  3. if strcomp(rs!Name,srchtext,vbTextcompare)=0 and strcomp(rs!RegNumber,srchnum,vbTextcompare)=0 then
  4. msgbox "Record found RecoedId: " & rs!RecordID,Vbinformation
  5. end if
  6. rs.movenext
  7. next


i hope this code will help you,

with regards
Venkatramasamy SN
Last edited by venkatramasamy; Jan 8th, 2008 at 5:42 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 24
Reputation: pranavdv is an unknown quantity at this point 
Solved Threads: 0
pranavdv pranavdv is offline Offline
Newbie Poster

Re: Find Record

 
0
  #3
Jan 8th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 71
Reputation: venkatramasamy is an unknown quantity at this point 
Solved Threads: 12
venkatramasamy's Avatar
venkatramasamy venkatramasamy is offline Offline
Junior Poster in Training

Re: Find Record

 
1
  #4
Jan 9th, 2008
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...

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub form_load()
  2. cbmIncome.additem("Cash")
  3. cbmIncome.additem("Cheque")
  4. end sub
  5. Private Sub cmdFind_Click()
  6. rn = InputBox("Enter Receipt No", "Find")
  7. 'MsgBox (rn)
  8. Adodc1.Recordset.MoveFirst
  9. For j = 0 To Adodc1.Recordset.RecordCount - 1
  10. If StrComp(Adodc1.Recordset.Fields("recno"), rn, vbTextCompare) = 0 Then
  11. TxtRecpt.text=Adodc1.Recordset.Fields("recno")
  12. Txtdate.text=Adodc1.Recordset.Fields("date")
  13. TxtPname.text=Adodc1.Recordset.Fields("Partyname")
  14. cbmIncome.text=Adodc1.Recordset.Fields("IncomeType")
  15. else
  16. MsgBox "No records available with the Enteres receipt no", vbInformation + vbOKOnly, "Record"
  17.  
  18. End If
  19. Adodc1.Recordset.MoveNext
  20. Next
  21. end sub

hope this code will help you,

With regards
Venkatramasamy SN
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 24
Reputation: pranavdv is an unknown quantity at this point 
Solved Threads: 0
pranavdv pranavdv is offline Offline
Newbie Poster

Re: Find Record

 
0
  #5
Jan 9th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 71
Reputation: venkatramasamy is an unknown quantity at this point 
Solved Threads: 12
venkatramasamy's Avatar
venkatramasamy venkatramasamy is offline Offline
Junior Poster in Training

Re: Find Record

 
0
  #6
Jan 9th, 2008
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...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2.  
  3. Private Sub form_load()
  4. cbmIncome.additem("Cash")
  5. cbmIncome.additem("Cheque")
  6. end sub
  7. Private Sub cmdFind_Click()
  8. dim Rfound as boolean
  9. Rfound=false
  10. rn = InputBox("Enter Receipt No", "Find")
  11. 'MsgBox (rn)
  12. Adodc1.Recordset.MoveFirst
  13. For j = 0 To Adodc1.Recordset.RecordCount - 1
  14. If StrComp(Adodc1.Recordset.Fields("recno"), rn, vbTextCompare) = 0 Then
  15. TxtRecpt.text=Adodc1.Recordset.Fields("recno")
  16. Txtdate.text=Adodc1.Recordset.Fields("date")
  17. TxtPname.text=Adodc1.Recordset.Fields("Partyname")
  18. cbmIncome.text=Adodc1.Recordset.Fields("IncomeType")
  19. Rfound=true
  20. Exit for
  21. else
  22. Rfound=false
  23. End If
  24. Adodc1.Recordset.MoveNext
  25. Next
  26.  
  27. if Rfound=false then
  28. msgbox "ReceiptNumber Not found", Vbinformation
  29. end if
  30.  
  31. end sub

reply me about the status

With regards
Venkatramasamy SN
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 24
Reputation: pranavdv is an unknown quantity at this point 
Solved Threads: 0
pranavdv pranavdv is offline Offline
Newbie Poster

Re: Find Record

 
0
  #7
Jan 9th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 71
Reputation: venkatramasamy is an unknown quantity at this point 
Solved Threads: 12
venkatramasamy's Avatar
venkatramasamy venkatramasamy is offline Offline
Junior Poster in Training

Re: Find Record

 
0
  #8
Jan 9th, 2008
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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC