Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enter key in text box cancels window

Status
Not open for further replies.

shyamal

Programmer
Aug 14, 2000
79
US
I have a form, with a text box and a cancel button.
When i enter text in the box and hit the enter key, the window closes. My guess is that it is acting like the cancel button. Therefore within the properties of the cancel button, I changed the cancel property to False. Originally set to True. This does not have any effect clicking the enter key in the text box still closes the form.
 
There is another part to this code. There are two buttons on the form: Save and Cancel

The code for the Cancel button is:mbUserCancelled = True
The code for the Save button is: mbUserCancelled = False
If these are commented out and the cancel button, cancel property is set to False, the enter key now functions as a save key.
So now the current scenrio is load the form, enter text in text box, click enter to go to the next line and instead the text gets saved.
 
Solved the problem:

With frmaddcomment

...
.cmdSavecomment.Enabled = True
.cmdCancelcomment.DEFAULT = False
.txtSscomment.Text = " "
.txtSscomment.Locked = False
.Show vbModal
DoEvents
If Not .mbUserCancelled Then
'Do save
szComment = .txtSscomment.Text

Else
'User cancelled
.mbUserCancelled = True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top