Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Record pointer in listbox out of synch when adding a rec
Message
From
10/05/2001 07:34:11
 
 
To
10/05/2001 02:58:53
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00505635
Message ID:
00505662
Views:
26
Hi Jang,

It sounds like you might need to do a requery on the listbox to make it show the record you have just added
Also the thisform.refresh you do after adding the record... I suspect the listbox will move the record pointer to a record that it can see (if you haven't done a requery it will move off the newly added record).

Also remember that a newly added record will have a record numner of -1 for buffered tables.

My advice is to step through the add & save record process and see what's changing things

HTH

>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
Will Jones
Previous
Reply
Map
View

Click here to load this message in the networking platform