Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When is TableUpdate Needed for CursorAdapter?

Status
Not open for further replies.

dantheinfoman

Programmer
May 5, 2015
131
US
Hi All,

Is there a function to know whether the cursor (that the CursorAdapter uses to update the table) has been changed? If changes are made to my grid and somebody tries to exit out without clicking Save, I'd like a message to ask if they'd like to Save (meaning do a TableUpdate(.T.) ) or not if they wanted to discard buffered changes.

Thoughts?

Thanks

Dan
 
Olaf! Friggin Brilliant!!!!


I just stumbled onto some legacy code that looks similar, but I like your direct approach. Here's what they used:
Code:
WITH ThisForm
   RETURN GETFLDSTATE(-1, .r_cMasterAlias) <> ;
      REPLICATE("1", LEN(GETFLDSTATE(-1, .r_cMasterAlias)))
ENDWITH
Thanks.
Dan
 
GetNextModified() and GetFldState() work together nicely. GetNextModified lets you find the records that have been modified. GetFldState() lets you figure out what changes in those records.

Tamar
 
Hi Tamar and Olaf,

I'm having serious trouble with records becoming duplicated (or rather copying over the next record) in my CursorAdapter. I can start a new topic, but its very similar in that it's regarding my CursorAdapter.

I tried adding more to my KeyFieldList, so that now it's the majority of the fields,
Code:
KeyFieldList = "PROSPCT_NO,CTYPE,DATE,COMTOP,CONFER,SHCOMM"
Alias = 'supplmt'
CursorSchema = 'PROSPCT_NO N(6, 0), CTYPE C(3), COMTOP C(3), C_IMPORTED L, CONFER C(3), DATE D, IMPORT_DAT D, CREATEDATE D, USER_ID C(10), ALERTED L, SHCOMM M,contact c(30)'
DataSourceType='Native'
SelectCmd = 'select prcomm.ctype,prcomm.comtop,prcomm.confer,prcomm.date,prcomm.shcomm,prcomm.c_imported,prcomm.import_dat,PRCOMM.contact,prcomm.user_id,prcomm.createdate,prcomm.PROSPCT_NO,prcomm.alerted,PRCOMM.company from PRCOMM LEFT JOIN PRPRSPCT on prcomm.prospct_no=prprspct.prospct_no'
Tables = 'PRCOMM,PRPRSPCT'
UpdateableFieldList = 'PROSPCT_NO,CTYPE,COMTOP,C_IMPORTED,CONFER,DATE,IMPORT_DAT,CREATEDATE,USER_ID,ALERTED,SHCOMM'
UpdateNameList = 'PROSPCT_NO prcomm.PROSPCT_NO,CTYPE prcomm.ctype,COMTOP prcomm.comtop,C_IMPORTED prcomm.c_imported,CONFER prcomm.confer,DATE prcomm.date,IMPORT_DAT prcomm.import_dat,CREATEDATE prcomm.createdate,USER_ID prcomm.user_id,ALERTED prcomm.alerted,SHCOMM prcomm.shcomm,contact PRCOMM.contact,company PRCOMM.company'
UseDeDataSource = .F.

**and in the init I have it set to buffering using
=cursorsetprop("buffer",5,"supplmt")

Is it right in front of me and obvious to everybody but me? I'm so confused why these are clustering like this.


It looks like this in the grid and works at first,but at some point it decides 2 or more records are identical and to overwrite all of them as the same thing:

1.
Screen_Shot_06-17-16_at_03.56_PM_n8o55s.gif


2. try to change date and comment field on one, then hit button for TableUpdate(.T.)
Screen_Shot_06-17-16_at_03.57_PM_z8sslj.gif

3. After tableupdate(.T.) and running the query again, it's still jacked up.
Screen_Shot_06-17-16_at_03.57_PM_001_q7c6k1.gif



Does anyone know what I'm doing wrong?

Thanks

Dan
 
Your table should better have one field for the primary key. It's value must be unique in all data.

Bye, Olaf
 
Hi Olaf,

I've just added (successfully) to the KeyFieldsList a new field I made called COMUNIQ C(10), wherein I put Sys(2015) whenever appending. I did a
REPL COMUNIQ WITH SYS(2015) ALL for the current records and now even if all three records match exactly on the grid and I change one or more, they all update according to their own record.

Thanks!! :)

Dan
 
Set the Keyfieldlist to only this field. SYS(2015) is not perfect, but okay for small number of clients. If you ever have automatic data logging with high frequency from several clients SYS(2015) can overlap, by definition of it it'll never break uniqueness on a single PC, but can do so from many.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top