How to instruct the user to press button

aman

Registered User.
Local time
Today, 09:07
Joined
Oct 16, 2008
Messages
1,251
Hi All

I have a form in which when the user types surname in a textbox then focus goes to command button(Enter). when the user presses enter then a form is displayed which shows all the names matches with the surname typed in a textbox. Sometimes the user doesn't press enter button so I want a vba code to force the user to press enter before doing anything else.

I know I can write the vba code on the next control got focus event but not sure how.

I hope anyone can help me in this.

Thanks
Aman
 
a few different approaches ...


1. why bother with the button

use the after update for the text entry box
as soon as they exit, it will test the name

-----------
also perhaps allow the dble-click to test at any time

--------
another way is to use a combo-box

in the after update for the name - then have a combo box to show all the matching names

in fact, i might well do this with 2 combo boxes - 1 to select the surname, and then the second to choose between all the matching choices - this is cascading combo boxes - which is a common technique

---------
for completeness - to do it your way
in the afterupdate for the name field, set a form "needschecking" boolean variable to true

then set it to false in the button click event.

the trouble is you THEN have to either
a) set all the other fields/controls as inactive/active depending on the needschecking flag OR
b) put code everywhere to force the user to click the button, if needschecking is true

its much easier to click it for him, effectively
 
Or, if you still want to have the button and have the code on the button you can set the buttons "DEFAULT" property to YES. Then, if they enter information and hit their Enter/Return key it will "click" the button automatically, just as if you did it like some web pages or other programs have it.
 
Thanks Gemma-the-husky and boblarson for your help.

I have removed the Enter button and used the Afterupdate event and everything works perfectly fine. Also I have set the default property to Yes for other command buttons as I didn't know the purpose of Default property of a button earlier.

Thanks guys.
 
Once it becomes hard for database to display suggestion list with every letter typed, Timer event can be used to update list once in few seconds (if text changed).
 
Once it becomes hard for database to display suggestion list with every letter typed, Timer event can be used to update list once in few seconds (if text changed).

That makes no sense at all in regards to this thread. Still trying to advertise the program by posting inane answers to different threads, eh?
 
boB! i like your new avatar - very good likness! ;P
 
That makes no sense at all in regards to this thread.
Why are you so sure? If Aman needs to show some suggestions, then he has a lot of people in that database. When amount of records grow and number of people using database increase, fulltext search queries will need more and more time to complete. Being bind to OnUpdate event handler that delay will turn typing in pain.

So whats wrong with my suggestion?

Still trying to advertise the program by posting inane answers to different threads, eh?
In order not to offtopic here, please PM me with my inane answers examples.
 
Bob

(repeating an earlier post, which you didnt see/didnt answer)

--------------------------------------------------------------------------------

i didnt know you could auto-click a command button in the way you describe, Bob

is the possibility you outline the only reason to have this facility - ie tab there from another field, and auto click - or is there any other reason it would be useful
 
Bob
is the possibility you outline the only reason to have this facility - ie tab there from another field, and auto click - or is there any other reason it would be useful
I'm not sure I understand that question. I has me confused slightly.

Basically, just as in VB6, you can set the button's DEFAULT property to be YES and then anytime you are on that form you can hit your enter key to run the click event for that button without clicking the button.

And, if you set the button's CANCEL property to YES, then if you hit the ESC key, it will be as if you clicked that button.

A form can only have one button set to DEFAULT = YES and one DIFFERENT button set to Cancel = YES.

Hopefully that helps.
 
bob

i wondered why you would have a button with one click event that effectively you didn't HAVE to click to get it to fire.

form what you are saying,
all you have to do is tab into it, as the next control, and it will click itself automatically.

I was struggling to see a lot of uses for this sort of functionality.
 
Last edited:
bob

i wondered why you would have a button with one click event that effectively you didn't HAVE to click to get it to fire.

form what you are saying,
all you have to do is tab into it, as the next control, and it will click itself automatically.
No, you have to hit your enter key but it can be done from any location. So, for example if you have a search form where you fill in one or two of 10 controls and hit your enter key, it would save you having to grab your mouse and click the button. It is like that on a lot of websites too. They have a button to "run" the query but you can typically just enter the text in the search field and hit your enter key (also known as return) and it will go do the search without having to click on the button.
 

Users who are viewing this thread

Back
Top Bottom