|
-
Dec 31st, 2002, 01:16 AM
#1
Thread Starter
Addicted Member
How can help to correct this code plz?
Hi Guys
I use the code below to search for employee , by using the employee number.
In the form I have only listview1 and text1 box for search.
Databse: dbemp
Recordset:rsemp
When I use this code I always get this message
Invalid property value , err 380
Any one can help please ?
Thank you in advance
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim x As ListItem
Set x = ListView1.FindItem("emp_number", lvAccounts, elvSearchText)
If (x Is Nothing) = False Then
Set lvAccounts.SelectedItem = x.Selected
End IfEnd Sub
-
Dec 31st, 2002, 01:45 AM
#2
Well ...
Try changing the following line:
VB Code:
'Change this line ...
Set lvAccounts.SelectedItem = x
'To this line ...
x.Selected is a boolean (Yes/No) property, while the lvAccounts.SelectedItem is an object property (i.e. it holds a ListItem object).
.
-
Dec 31st, 2002, 02:22 AM
#3
Thread Starter
Addicted Member
Re: Well ...
Hi honeybee
Thank you
I tried this Set lvAccounts.SelectedItem = x
Instead of Set lvAccounts.SelectedItem = x.Selected but, does not work
Can you post anther idea please ?
Thank you so much
QUOTE]Originally posted by honeybee
Try changing the following line:
VB Code:
'Change this line ...
Set lvAccounts.SelectedItem = x
'To this line ...
x.Selected is a boolean (Yes/No) property, while the lvAccounts.SelectedItem is an object property (i.e. it holds a ListItem object).
. [/QUOTE]
-
Dec 31st, 2002, 03:19 AM
#4
Well ...
Oh boy! You said you are using only one Listview and one textbox. But you are using the name of the listview control as ListView1 at one place and lvAccounts at the other. Verify your code and use the same listview name at both the places.
Did you copy the FindItem line from somewhere?
.
-
Dec 31st, 2002, 03:38 AM
#5
Thread Starter
Addicted Member
Re: Well ...
NO, Sir
I did not copy any , I am using the same code which has only one listview with one textbox, and I need to search by suing the emp_number in the textbox, so can you help again to correct the code if you do not mind please ?
Thank you
Originally posted by honeybee
Oh boy! You said you are using only one Listview and one textbox. But you are using the name of the listview control as ListView1 at one place and lvAccounts at the other. Verify your code and use the same listview name at both the places.
Did you copy the FindItem line from somewhere?
.
-
Dec 31st, 2002, 09:15 AM
#6
Addicted Member
You did not fully answer Honeybee's question...also in your FindItem method, you have quoted your search variable, ie "emp_number", which makes it a constant...
Disclaimer:
* The preceding message was in no means meant to be critical, mean spirited, insincere, or facetious.
Disclaimer for disclaimer:
The preceding disclaimer may in fact be facetious in nature.
Thanks,
Jim
-
Dec 31st, 2002, 09:40 AM
#7
Fanatic Member
Here's some code for searching a Listview.
I would recommend doing the searching in the change event.
The following code should work
VB Code:
Private Sub text1_Change()
Dim Item As ListItem
Set Item = listview1.FindItem(text1, , , lvwPartial)
If Item Is Nothing Then
Exit Sub
Else
Item.EnsureVisible
Item.Selected = True
End If
End Sub
It Never Fails. Everytime I try to make a program idiot proof, the world makes a better idiot.
-
Dec 31st, 2002, 09:44 AM
#8
Lively Member
1. As noted above, you have two different names for your listview
2. Again as noted above, you use "emp_number", which may be in your recordset somewhere, but may not be the key to the listview item. Nowhere in that procedure do you set "emp_number". Once you use the recordset to populate the listview, you don't care about it as far as searching the listview is concerned.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|