Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
switch
case fld "Job" <> "" and fld "Emp" = ""
put revQueryDatabase( theConnectionID, "SELECT * FROM cjp WHERE job='" & tJob & "'") into theCursor
case fld "Emp" <> "" and fld "Job" = ""
put revQueryDatabase( theConnectionID, "SELECT * FROM cjp WHERE employee='" & tEmp & "'") into theCursor
case fld "Emp" = "" and fld "Job" = ""
put revQueryDatabase( theConnectionID, "SELECT * FROM cjp") into theCursor
case fld "Emp" <> "" and fld "Job" <> ""
put revQueryDatabase( theConnectionID, "SELECT * FROM cjp WHERE employee='" & tJob & "' and job='" & tEmp & "'") into theCursor
end switch
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
if fld "Job" <> "" then
put 1 into tcJob
else
put 0 into tcJob
end if
if fld "Emp" <> "" then
put 1 into tcEmp
else
put 0 into tcEmp
end if
put tcJob & tcEmp into tcJobEmp
put tcJobEmp into fld "Field11"
if theConnectionID is an integer then
## Query the database for data
switch
case tcJobEmp = "10"
put revQueryDatabase( theConnectionID, "SELECT * FROM cjp WHERE job='" & tJob & "'") into theCursor
case tcJobEmp = "01"
put revQueryDatabase( theConnectionID, "SELECT * FROM cjp WHERE employee='" & tEmp & "'") into theCursor
case tcJobEmp = "00"
put revQueryDatabase( theConnectionID, "SELECT * FROM cjp") into theCursor
case tcJobEmp = "11"
put revQueryDatabase( theConnectionID, "SELECT * FROM cjp WHERE employee='" & tJob & "' and job='" & tEmp & "'") into theCursor
end switch
I added Field11 just to see that the if/else is working and it is
but I still get nothing
it has to be related to my switch statement, befor I added the Emp, and I just had an If/else statement with job only it worked fine.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
...
switch
case tcJobEmp = "10"
put revQueryDatabase( theConnectionID, "SELECT * FROM cjp WHERE job='" & tJob & "'") into theCursor
BREAK
case tcJobEmp = "01"
put revQueryDatabase( theConnectionID, "SELECT * FROM cjp WHERE employee='" & tEmp & "'") into theCursor
BREAK
case tcJobEmp = "00"
put revQueryDatabase( theConnectionID, "SELECT * FROM cjp") into theCursor
BREAK
case tcJobEmp = "11"
put revQueryDatabase( theConnectionID, "SELECT * FROM cjp WHERE employee='" & tJob & "' and job='" & tEmp & "'") into theCursor
BREAK
end switch
...
If you leave out BREAK then ALL cases will be executed
Why not simplify this, and eliminate the switch. Just have four separate if statements. In other words, take the actions from your switch, and put them into the if statements that do your evaluation.