I have a listbox that the user enters values (amounts) in one of the cells and what I want to happen is for the listbox to advance to the next row and same cell as they hit the enter or return key.
I’ve tried putting the following code in the “celllostfocus” and the “cellkeydown” and the listbox’s keydown but nothing seems to work.
celllostfocus:
me.editcell(row+1,column)
cellkeydown:
if key = cur(13) or key = chr(3) then
me.editcell(row+1,column)
end
listbox’s keydown: (nRow and nColumn are set by the cellgotfocus)
if key = cur(13) or key = chr(3) then
listbox.editcell(nRow+1,nRowcolumn)
end
The behavior I’m getting is when I press the enter or return key, the value enter in the cell is saved, but no advance.
Any help appreciated and I didn’t see this addressed anywhere in the forums.
Here is the best I’ve been able to come up with. Might be of use to someone else:
I added this code to the listbox.keydown
This listbox has 4 columns: AC, ACName, Debit, Credit
The user will be entering debit and credit balances for each account.
It appears that when you are editing a cell XOJO and you press the ENTER / RETURN key that terminates the edit but you can’t use the listbox.editcell to immediately tell it to edit another cell. I have that line of code marked in the code fragment below.
I trap for the last key so if they moved the row up or down, I don’t want to advance to another row or immediately edit the cell.
Anyone got a fix for this or is that just the way it is?
'----------------------------------------------- listbox.keydown
dim nReturn As Boolean
if nRow < me.ListCount then
'--- DOWN ARROW, RETURN KEY, ENTER KEY
if AscB(key) = 13 or AscB(key) = 3 then
'--- LAST KEY WAS NOT UP ARROW OR DOWN ARROW - MOVE DOWN ONE ROW
if nLastkey <> 30 AND nLastkey <> 31 then
me.ListIndex = nRow + 1
'--- THIS DOES NOT WORK!!!
me.EditCell(nRow+1,Column)
end
nReturn = True
end
end
'— LEFT ARROW - MOVE TO DEBIT COLUMN
if AscB(key) = 28 then
me.EditCell(nRow,2)
nReturn = True
'--- RIGHT ARROW - MOVE TO CREDIT COLUMN