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!

keyascii 13 1

Status
Not open for further replies.

kimtp

Programmer
Jun 15, 2002
310
US
Am trying to navigate a sstab form using keyascii = 13 and keyascii = 0. Works as intended until I throw in a chk box. Not when the chk box is unchecked, only after it is checked I get 'invalid procedure or call arguement' msg. Seems that I am not resetting something but don't know what to do.

Here is some of the code that causes the error:

Private Sub txtLastname_KeyPress(KeyAscii As Integer)
KeyAscii = 0
txtAddress.SetFocus
End Sub

Thanx.

Kim
 
It appears that there may be some missing code from your posting. As it stands, any keystroke will move the focus from the Lastname textbox to the address textbox. Is there a conditional (if keyascii = 13) missing from the post?

Your post also indicates that a checkbox seems to be a player in the scenario, but your code provides no indication of what role the checkbox is playing.

That being said, from a general standpoint, I would insure that whatever control is going to be receiving the focus is visible and on the current tab, and is enabled before attempting to giving it the focus. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Whoops. Let me do this again. The correct code is:

Private Sub txtLastname_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
txtAddress.SetFocus
End If
End Sub

The checkbox is number 6 downstream after, address, city, state, zip, country then checkbox. If it is unchecked then it works as intended. If I call a record that has the checkbox.value = True then after hitting enter when the cursor is in txtlastname.text, the message appears.

The message also appears if I check the checkbox and then continue onto the next and succeeding tabs. When I press enter and get to txtLastname.text, the message rears its' ugly head.

When using the tabkey to navigate with the same record as mentioned above, it jumps to the checkbox. Without any record present both the tab and enter keys goto the address text box.

Tab index for all boxes is one more than the label for the textbox. In this case 1,3,5,7,9,11,13 and the check box is 14. All controls are on the same tab which is on a frame.

Thanx.

Kim
 
Hi, Kim...

I suggest the following:

Set True the KeyPreview property of the form, and capture the pressed key in the Form_KeyPress event instead of the txtLastName_KeyPress event and so on. Your code should look like this:

Private Sub Form_KeyPress(KeyAscii as Integer)
Select Case ActiveControl.Name
Case "txtAddress"
txtCity.SetFocus
Case "txtCity"
txtState.SetFocus
Case "txtState"
txtZip.SetFocus
End Select
End Sub
 
sglugove,

Appears that any keypress will move the cursor to the next textbox. In fact, with your code only one keypress is allowed.

On the other hand, If I put this into your case select:

If keyascii = 13 then
keyascii = 0
txtnexttextbox.setfocus
end if

how does the modified version of what you describe differ from the original?

Thanx.

Kim
 
What does the checkbox click event look like? Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
CajunCenturion -

Thanx for the heads up. Spotted a couple of things that need attention before I can do the set focus bit.

Kim
 
Hi, Kim, you're right!

Of course you have to filter the KeyAscii = 13 with an "if" instruction before the "Select Case" statement...

By the way, I'm sorry for my english...

Regards,

sglugove
 
Thanx to all for the help. Learned from every response. I think I got it to work without a glitch. But I'm sure . . .

There is one concern though, if I do not use the enter key, the tab key works according to the tabindex. But if I use the enter key, go back one control then use the tab key, the program does not follow the tab index set in the properties box.

Any ideas would be great.

Also, is the horizontal tab keyascii 9? And what about the shift key, is it 14 or 15?

Thanx.

Kim
 
Keyascii from the Keypress event only returns printable characters, not Tab or Shift keys.

You can catch Shift key (Keycode 16) from the KeyDown event
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
What I'm trying to do is to navigate backwards using the tab and shift keys. Works when on the same tab, but won't go if I want to move backwards from tab to tab like the keyascii = 13 stuff above.

Any ideas are helpful.

Thanx.

Kim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top