field names is ok the same as in the database table.
the strange is when i go to save a record i get the "datatype mismatch error"
when i go in the field "customer_id" and lock the text from the inspector the data is saved ok..without "datatype mismatch error"
there is no fields locked in the card,is clean for data enter..
Can anyone tell me where i do wrong?
code in the card
Code: Select all
on opencard
set the useUnicode to true
set the dontWrap of field customer_info to false
set the visible of btn"save_thecustomer" to false
set the visible of btn"start1" to false
put empty into image "cPhoto"
put empty into fld "customer_photo"
// empty the fields
if fld "customer_id" is empty then
else
repeat with x = 1 to number of fields
if not the lockText of fld x then
put empty into fld x
end if
end repeat
end if
#fill the data for option box
dbcolumns "first_name,last_name"
put dbGet("customers") into myRecords
repeat for each key tKey in myRecords
put myRecords[tKey]["first_name"] && myRecords[tKey]["last_name"]& CR after tOptionMenuList
end repeat
## Delete trailing CR
delete char -1 of tOptionMenuList
## Fill option button for unicode text
set the unicodetext of btn "myopt" to uniencode(tOptionMenuList,"utf8")
end opencard
Code: Select all
on mouseUp
# This command will look into the current card for fields, buttons and groups
# with the same name as the fields on a given database table. If it finds the correct controls
# it picks their values and assemble an array to be used by the database touching functions.
put dbCardToArray("customers") into MyRecords
//if no text into field
put the text of fld "first_name" into mRec
switch MyRecords
case mRec
if mRec is empty then
set the backgroundcolor of fld "first_name" to "red"
answer "No Records" with "OK"
wait 10 milliseconds
set the backgroundcolor of fld "first_name" to "white"
end if
break
case MyRecords
if field "customer_id" is empty then
//Insert the records into table
get dbInsert ("customers",MyRecords)
if it is a number then
answer it && "New Record Saved"
else
answer error it
end if
end if
end switch
end mouseUp