473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help on on key up event

Here's what I'm trying to do: I want to type in a combo box (search for
a Contact) and if that contact is not in the list, pop up a message box
asking the user if they want to add the contact. I've been told to put
the following code on the "on key up event" and that should work.
However, that pops up the box after only one key stroke. I type in a
"k" and it says, "K" is not an existing contact...do you want to add
them?

Is this correct code or should this be on the OnNotInList event and if
so,what would need to change?

Thanks in advance!!

Here's the code:

Private Sub cboSearchName_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode <vbKeyReturn And KeyCode <vbKeyBack Then
If DCount("NWContactID", "tblNWContact", "NWNameLast & ' ' &
NWNameFirst LIKE '" & Me.cboSearchName.Text & "*'") = 0 Then
If MsgBox("There is no existing contact whose name begins
with """ & Me.cboSearchName.Text & """." & _
vbCr & vbCr & "Would you like to add a new
contact?", vbQuestion + vbYesNo, _
"Contact Not Found") = vbYes Then
Me.cboSearchName = ""
Me.cmdAddContact.SetFocus
Call cmdAddContact_Click
Else
SendKeys Chr(vbKeyBack)
End If
End If
End If
End Sub

Nov 9 '06 #1
1 1910
Ummm, I would stick to the OnNotInList event. One of the developer's
handbooks has the good code for it, but it's pretty self explanatory,
and the online help is decent.

The code you have there checks every key press to see if there is a
contact that starts with the characters typed. While this would
probably work, it would get very slow with alot of contacts.
Chris
abprules wrote:
Here's what I'm trying to do: I want to type in a combo box (search for
a Contact) and if that contact is not in the list, pop up a message box
asking the user if they want to add the contact. I've been told to put
the following code on the "on key up event" and that should work.
However, that pops up the box after only one key stroke. I type in a
"k" and it says, "K" is not an existing contact...do you want to add
them?

Is this correct code or should this be on the OnNotInList event and if
so,what would need to change?

Thanks in advance!!

Here's the code:

Private Sub cboSearchName_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode <vbKeyReturn And KeyCode <vbKeyBack Then
If DCount("NWContactID", "tblNWContact", "NWNameLast & ' ' &
NWNameFirst LIKE '" & Me.cboSearchName.Text & "*'") = 0 Then
If MsgBox("There is no existing contact whose name begins
with """ & Me.cboSearchName.Text & """." & _
vbCr & vbCr & "Would you like to add a new
contact?", vbQuestion + vbYesNo, _
"Contact Not Found") = vbYes Then
Me.cboSearchName = ""
Me.cmdAddContact.SetFocus
Call cmdAddContact_Click
Else
SendKeys Chr(vbKeyBack)
End If
End If
End If
End Sub
Nov 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
2
by: Wayne Wengert | last post by:
This is my first attempt to re-write an old VB6 application that exported a CSV file to a .NET application that exports an XML file with the equivelent data. I have limited understanding of OO...
3
by: Steve Long | last post by:
Hello, I have a VB.NET class that raises a MapSet event that passes an argument of type interop.MapObjects2.MapClass. I have a C# class that inherits from this VB.NET class. How can I handle the...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
22
by: Jeff Louie | last post by:
Well I wonder if my old brain can handle threading. Dose this code look reasonable. Regards, Jeff using System; using System.Diagnostics; using System.IO; using System.Threading;
0
by: Tiraman | last post by:
Hi , i m getting the following errors under the eventlog while i m trying to run some class that i wrote. at the first i got an error about the just-in-time : access denied and i added the...
4
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
0
by: Guilherme Polo | last post by:
On Wed, Sep 3, 2008 at 8:57 PM, Kevin McKinley <kem1723@yahoo.comwrote: Come on.. "help on lines 384-403", that is not a good way to look for help. You are supposed to post some minimal code that...
24
by: Joe, G.I. | last post by:
Can anyone help me w/ a priority_queue. I'm generating MyEvent classes and I put them on a priority_queue, but I don't know how to get them in priority. The priority is the event w/ the smallest...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.