General information
Category:
Forms & Form designer
Hi Jang,
I don't know if this will help but how about doing the refresh in your add code before doing the setfocus?
Hope his helps,
Gavin...
>When building a form to display some fields,I
>encountered the following :
>I have 7 fields in my form (6 of which are textboxes
>and 1 general for picture). Besides these 7 elements
>in the form I have also put in a listbox displaying
>the records of the table. I have no problem going
>form record to record, go top, go bott etc, and the
>form displays fine, and the listbox with its highlight bar
>pointing correctly at the corresponding record.
>
>When I tried adding records (after pressing the
>add button), the textboxes do go blanks and focus
>was set at the first field as desired, but the highlight
>bar in the listbox disappeared. When save-record
>was issued, the newly entered record was found
>overwriting the record the listbox was pointing at
>right before adding. By scrolling up and down the
>list, a blank record was found at the top of the list.
>My guess is that APPEND BLANK had indeed
>added a new record to the table, but somehow the
>pointer wasn't updated to point to the new record.
>Instead it sits at where it was originally and thus
>an add-record had become an edit-record.
>
>I have tried a number of things including playing
>with the control source, en/disabling the listbox during
>add, changing the codes in the add button click event,
>playing with the datasession and dataenvironment,
>and I still couldn't get it to work. Could somone please
>tell me what I have done wrong? Any help would
>be appreciated.
>
>PS: the following is in my addbutton.click :
>
>IF NOT EOF()
> THISFORM.oldRecNo = RECNO()
>ENDIF
>APPEND BLANK
>THISFORM.itemNum1.SETFOCUS()
>THISFORM.refresh()
>
>In my savebutton.click:
>
>result = TABLEUPDATE(.F.,.T.,"Items")
>IF !result
> =MessageBox(" Record save unsuccessful ",48," Item ")
> RETURN
>ENDIF
>IF INLIST(THISFORM.opcode,1)
> THISFORM.opcode = 4
> THISFORM.onOffBtn1(2)
> THISFORM.refresh()
>ENDIF
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only