index on 2 different field-types

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

index on 2 different field-types

Post by ROBROS »

Maybe the following code is of use for new "clipper" users.

In the table spesen.dbf only one date-entry per persnr is allowed.
To avoid that more than one entry is keyed in, I use this:

Code: Select all

 function chkpersdat // check if a record in spes exists for persnr+datum 
 cPersnr:=new_spes.pnr_1.value //active window.textbox.typed in-value
 dDat:=new_Spes.datum1.value //typed in as (in German /century on) 15.01.2018="20180115" in clipper a date field (fieldname,D)
 cdat:=dtoc(dDat) //shown in German (eg MsgInfo(' 15.01.2018 ') 
 use spesen alias spes new
// indexed on persnr+dtos(datum) to persdat                                  
// persnr is a char Field, datum comes from date-type textbox, index only possible on equal field types
// so converting field datum to a string is necessary
 cDatum:=dtos(new_Spes.datum1.value // value comes from date Type textbox
 MsgInfo(cPersnr)
 MsgInfo(cDat)
 select spes
 seek cpersnr+cdatum
 if found()
    MsgInfo(cPersnr+" / "+cdat+" alraedy existing")
    new_Spes.datum1.SetFocus    //go back to textbox datum1
 endif
 return
Regards
Robert
Post Reply