>Using VB6, I have a search form that displays records in a grid. In the KeyPress() and DblClick() of the grid I issue:
>
> '''
> ln_code = mygrid.Columns.Item(0)
> form2.custno = ln_code
> form2.Show
> '''
>
>If I double click on the grid, the 2nd form displays correctly and has focus.
>
>If I press enter on the grid and my grid's keyPress() is called, the 2nd form displays but focus is returned to the 1st form.
>
>Why does the same code work differently from the DblClick() and Keypress events?
>
>How can I ensure that the 2nd form gets focus and stays on top?
>
>Thanks,
>
>Jerryt
because in the keypress event, the event is triggered before the key is released, launch your other form and come back to continue executing on form1.
Try adding a "keyascii = 0" at the start of the keypress event or use the keyup event.
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com