By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,083 Members | 1,608 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,083 IT Pros & Developers. It's quick & easy.

Find and bookmark function of adodc to a data control

P: 55
hi! in my program i'm using the find and bookmark function of the adodc control. as the people want me to use a normal data control, when i tried to run it using the same commands i've got an error. is there any other way to do this function through a data control? i'll post on what i've got but i it seems no to work. can anyone help me pls..

Expand|Select|Wrap|Line Numbers
  1. Dim counter As Integer
  2. counter = 0
  3. adoEmployee.Recordset.MoveFirst
  4. Do While adoEmployee.Recordset.EOF
  5.     MsgBox (adoEmployee.Recordset.Fields(0).Value)
  6.     If txtInputID.Text = adoEmployee.Recordset.Fields("EmployeeID").Value Then
  7.         counter = 1
  8.     End If
  9.     adoEmployee.Recordset.MoveNext
  10. Loop
  11. If counter = 0 Then
  12.     MsgBox "Employee ID does not exist", vbInformation, "Find Failure"
  13.     txtInputID.Text = ""
  14.     txtInputID.SetFocus
  15.     adoEmployee.Recordset.MoveFirst
  16.     Exit Sub
  17. End If
Nov 26 '07 #1
Share this Question
Share on Google+
6 Replies


QVeen72
Expert 100+
P: 1,445
Hi,

Why Loop through complete Record set. Use "Find" method of ADODC..

Check this out :

Expand|Select|Wrap|Line Numbers
  1. adoEmployee.Recordset.MoveFirst
  2. adoEmployee.Recordset.Find "EmployeeID='" & txtInputID.Text & "'"
  3. If adoEmployee.Recordset.NoMatch Then
  4.     MsgBox "No Matching Record Found"
  5. Else
  6.    MsgBox "Match Found ,..Name Is  " & adoEmployee.Recordset("EmpName")
  7. End If
  8. End If
Regards
Veena
Nov 26 '07 #2

P: 55
Hi,

I've tried what you said but it doesn't work. an error i got (object doesnt support property or method) its probably because i'm not using adodc, im using a normal data control (sorry if the naming got you confused) does anyone know how to find using normal data control?

** what i mean about normal data control is the one that's is already in the toolbox without adding components
Nov 27 '07 #3

lotus18
100+
P: 866
Hi jaz215

Expand|Select|Wrap|Line Numbers
  1. Dim counter As Integer
  2. counter = 0
  3. adoEmployee.Recordset.MoveFirst
  4. Do While adoEmployee.Recordset.EOF
  5.     MsgBox (adoEmployee.Recordset.Fields(0).Value)
  6.     If txtInputID.Text = adoEmployee.Recordset.Fields("EmployeeID").Value Then
  7.         counter = 1
  8.     End If
  9.     adoEmployee.Recordset.MoveNext
  10. Loop
  11. If counter = 0 Then
  12.     MsgBox "Employee ID does not exist", vbInformation, "Find Failure"
  13.     txtInputID.Text = ""
  14.     txtInputID.SetFocus
  15.     adoEmployee.Recordset.MoveFirst
  16.     Exit Sub
  17. End If
When opening your recordset, try this:

Expand|Select|Wrap|Line Numbers
  1.      "Select * From <TableName> Where <FieldName>='" & Text1.Text & "'"
  2.  
Nov 27 '07 #4

P: 55
Hi lotus & queen!

I've found out what the problem is, there is no find in datacontrol only findfirst :P (i thought the code was correct as there were no error before i run it) sorry for the trouble you guys! thanks for the help!
Nov 27 '07 #5

QVeen72
Expert 100+
P: 1,445
Hi,
I've tried what you said but it doesn't work. an error i got (object doesnt support
Hi,

OK, My Coding was for ADODC. and yes, your naming got me confused.
For normal Data Control (call it as DAO's data control)
you can change the code (my previuos post) from
".Find" to ".FindFirst"
You must have got the error in this line..
Rest of the coding remiand same..

Regards
Veena
Nov 27 '07 #6

P: 55
Thanks Veena & Lotus!

Sorry about the coding convention it was my first time using the DAO :P
Nov 28 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.