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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update problem

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
585
PH
I have this code to update a record, but some times when i do updating its changes all in the database with the same record... so all records in the database have the same idnumber names surnames and other fields.... please help.... thanks and God bless...

PROCEDURE CmdUpdate.Click()

idpointer = this.Parent.cboidnum.value
IDNAMBER = this.parent.text1.value
neym = this.parent.text2.value
sneym = THIS.parent.TEXT3.VALUE
mobyle = this.Parent.text4.value
advyser = this.Parent.text7.value
eaddress = this.Parent.text8.value
especial = this.Parent.CboSpecial.value
sexx = this.Parent.CboSex.value
ctrr = 0
estatus = this.Parent.cbostatus.value
aay = ALLTRIM(STR(YEAR(DATE())))
ddatedit = DATETIME()
ggrade = "F"
mmode = "B"
*estatus = "Enrolled"
graded = this.Parent.text5.value
moded = this.Parent.cboMode.value

SELECT tsulat

IF FLOCK()

UPDATE TSULAT SET idnum = idnamber, fname = neym, sname = sneym, mobile = mobyle, adviser = advyser, eadd = eaddress, special = especial, ;
sex = sexx, ctr = 0, status = estatus, ay = aay, datedit = ddatedit WHERE idnum = idpointer

IF this.Parent.text9.value = 1

UPDATE tsulat SET grade = ggrade, mode = mmode, status = estatus WHERE idnum = idpointer

ELSE

UPDATE tsulat SET grade = graded, mode = moded WHERE idnum = idpointer

ENDIF

UNLOCK IN TSULAT

ELSE
WAIT WINDOW 'Unable to open MAIN Table; try again later!' NOWAIT
ENDIF

SELECT idnum, ALLTRIM(sname) + ", " + ALLTRIM(fname) FROM tsulat ORDER BY sname, fname INTO CURSOR csrdemo READWRITE

This.Parent.text1.value = " "
This.Parent.text2.value = " "
this.Parent.text3.value = " "
this.Parent.text4.value = " "
This.Parent.text5.value = " "
This.Parent.text7.value = " "
This.Parent.text8.value = " "
This.Parent.cboMode.value = " "
this.Parent.CboIdnum.value = " "
this.Parent.Cbospecial.value = " "
this.Parent.cbostatus.value = " "
this.Parent.cboSex.value = " "
This.Parent.text16.value = " "

ENDPROC
 
Mandy,

What are the data types of IDNum and IDPointer? Given that IDNum appears to come from a combo box, I'm guessing it is a character string. If that's the case, the result of [tt]WHERE idnum = idpointer[/tt] would depend on your setting of SET EXACT. Alternatively, you could do [tt]WHERE ALLTRIM(idnum) = ALLTRIM(idpointer)[/tt] or [tt]WHERE idnum == idpointer[/tt] (or both).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top