Hi Sherry.
>> In one of my form, I am using a list box control. Users can select any elements from the list. If the item does not exist( the listitemid will return -1) I would open another form so the users can enter a new item. I put that portion of the codes in the keypress event but it did not work. Where should I put the codes?? <<
You have me a little confused here. If you are using a scrolling List (i.e., a List Box), then the user can not select something that is not in the list. Are you really talking about a combo box here of style = 0 (drop down combo) where the user can type text into the text box portion of the control? If this is the case, code like this in the Combo's Valid method should do it for you:
IF !EMPTY( This.DisplayValue ) AND This.ListIndex = 0
DO FORM < MyForm > WITH loParameters TO lnRetVal
lnValue = IIF(lnRetVal = 0, This.Value, lnRetVal )
This.Requery()
This.Value = lnValue
ENDIF
Marcia