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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

call cmdsave_click from key press event..

Status
Not open for further replies.

sk1

Programmer
Oct 10, 2001
44
US
I have a form with many text boxes, the users either tab or by pressing enter key to move through each of the text boxes, once they enter the value in them. When they come to the last textbox(txtq28) to which they have to enter the value, I want

Once they enter the value in txtq28, and if they hit tab I want call the click event of the command button(cmdsave) which uses all the value and calculates the outlier and also saves the data.

Or if they hit enter after entering the value in txtq28, the same thing should happen. I tried doing this in couple of ways - by setting the default property of commnad button to Yes(this works but it won't allow them to exit other text boxes by hitting enter.

Or I tried putting this code in the keypress event of the q28, but it is not working what am I doing wrong.

Private Sub txtQ28_KeyPress(KeyAscii As Integer)
If (KeyAscii = vbKeyReturn) Then
'ENTER key is pressed
Call cmdSave_Click
end If
End Sub

there are couple of other text boxes after the q28 that are locked and display the results of the outlier.


In summary I need three ways to fire cmdsave_click -
1. by clicking on the cmdsave button.

2. by pressing enter in q28 text box.

3. and third by pressing tab on to q28. (This also is not working it gives some odbc -call failed error).

hope someone can help me.

thanks
 
on afterupdate event of txtq28 try
DoCmd.RunCommand acSave

Hope this helps
Hymn
 
This was very helpful Hymn, it took me in right direction
thank you.
 
I think this will work, i havnt tried it, but here goes:
Code:
Private Sub txtQ28_KeyPress(KeyAscii As Integer)
call ASCITest(KeyAscii)
end sub

private function ASCITest(KeyPressed as Integer)
 if keypressed=enter or keypressed=tab then
   call cmdsave_click
 end if
end function
i think that should work. I think rather than vbKeyReturn you should use the integer value, i think its 35 for enter.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top