Does this help?
var hODBCDLL : N12 = 0
var emp_lname : A16
var emp_fname : A12
var versie : A20 = "v1.0"
var updated : A50 = "01-01-2013"
var upd_by : A50 = "yourname "
var ISLName : A20 = "Clock In SIM"
//-------------------------------------------------------------------------------------------------
// 27-01-2006 Creation SIM File
//-------------------------------------------------------------------------------------------------
RetainGlobalVar
//-------------------------------------------------------------------------------------------------
// Event Inq: 1
// Event for clock in/out different employees
// it will check for a valid jobcode in the database and clocks in the employee on it's
// primairy job
//-------------------------------------------------------------------------------------------------
EVENT INQ: 1
If @UserEntry <> ""
call LookUpEmployee ( @UserEntry )
endif
ENDEVENT
//-------------------------------------------------------------------------------------------------
// Event CLOCKIN
// Event when the employee is clocked in
//-------------------------------------------------------------------------------------------------
EVENT CLOCKIN
InfoMessage "Welcome", "Welcome on the job ", emp_fname, " ", emp_lname
ENDEVENT
//-------------------------------------------------------------------------------------------------
// Event CLOCKOUT
// Event when the employee is clocked out
//-------------------------------------------------------------------------------------------------
EVENT CLOCKOUT
InfoMessage "Bye Bye", "Thanks for your efforts ", emp_fname, " ", emp_lname, ". See you next time"
ENDEVENT
//-------------------------------------------------------------------------------------------------
// Event Inq: 999
// Event Version Control
//-------------------------------------------------------------------------------------------------
EVENT INQ: 999
window 5, 50
Display 1, @Center, "ISL File Information: ", ISLName
Display 2, @Center, "------------------------------------------------"
Display 3, 2, "Version : ", versie
Display 4, 2, "Last updated : ", updated
Display 5, 2, "Updated by : ", upd_by
WaitForClear "Press Clear to continue"
WindowClear
ENDEVENT
//-------------------------------------------------------------------------------------------------
// SUB LookUpEmployee
// Search for ID and checks for a valid jobcode
//-------------------------------------------------------------------------------------------------
SUB LookUpEmployee (var UserEntry: N20)
var constatus : N9
var sql_cmd : A2000
var sLine : A100
var SEQ : N12
var ID : N10
var clock_in_key : key
clock_in_key = key(1, 655368)
if (@instandalonemode <> 1) or (@inbackupmode <> 1)
//-----------------------------------------------------------------
// WS4 and HHT only ...
//-----------------------------------------------------------------
//if (@WSTYPE = 2) or (@WSTYPE = 3)
// -------------------------------- Load SimODBC dll ---------------------------------
if hODBCDLL = 0
DLLLoad hODBCDLL, "MDSSysUtilsProxy.dll"
endif
if hODBCDLL = 0
exitwitherror "Failed to load MDSSysUtilsProxy.dll"
endif
//------------------------------------------------------------------------------------
// Connect to micros 3700 database
DLLCALL_CDECL hODBCDLL, sqlIsConnectionOpen(ref constatus)
if constatus = 0
DLLCALL_CDECL hODBCDLL, sqlInitConnection("micros","ODBC;UID=custom;PWD=custom", "")
endif
//Check if the employee exists in the database
format sql_cmd as "select emp_seq, ID, last_name, first_name from micros.emp_def ", "where obj_num = ", UserEntry
DLLCALL_CDECL hODBCDLL, sqlGetRecordSet(sql_cmd)
DLLCALL_CDECL hODBCDLL, sqlGetLastErrorString(ref sql_cmd)
if (sql_cmd <> "")
window 10, 70
display 1, 5, mid(sql_cmd, 1, 60)
display 2, 5, mid(sql_cmd, 61, 60)
display 3, 5, mid(sql_cmd, 121, 60)
ErrorMessage "Error from SQL"
else
DLLCALL_CDECL hODBCDLL, sqlGetFirst(ref sql_cmd)
if sql_cmd = ""
ErrorMessage "No employee in database with number: ", CHR(13), UserEntry
ExitCancel
else
while sql_cmd <> ""
splitQ sql_cmd, ";", SEQ, ID, emp_lname, emp_fname
DLLCALL_CDECL hODBCDLL, sqlGetNext(ref sql_cmd)
endwhile
endif
endif
//Checks if the employee has jobcodes and if so, then clock in with the primairy job
format sql_cmd as "SELECT * FROM micros.job_rate_def", " where emp_seq = ", SEQ, " and ob_primary_job = 'T'", " and ob_inactive = 'F'"
DLLCALL_CDECL hODBCDLL, sqlGetRecordSet(sql_cmd)
DLLCALL_CDECL hODBCDLL, sqlGetLastErrorString(ref sql_cmd)
if (sql_cmd <> "")
window 10, 70
display 1, 5, mid(sql_cmd, 1, 60)
display 2, 5, mid(sql_cmd, 61, 60)
display 3, 5, mid(sql_cmd, 121, 60)
ErrorMessage "Error from SQL"
else
DLLCALL_CDECL hODBCDLL, sqlGetFirst(ref sql_cmd)
if sql_cmd = ""
ErrorMessage "No jobcode for employee: ", CHR(13), emp_fname, " ", emp_lname
ExitCancel
else
while sql_cmd <> ""
loadkybdmacro clock_in_key, makekeys( ID ), @Key_Enter, @Key_Enter, @Key_Enter
DLLCALL_CDECL hODBCDLL, sqlGetNext(ref sql_cmd)
endwhile
endif
endif
else
ErrorMessage "POS Operations in Standalone/Backup Mode", "No connection with the database possible"
endif
ENDSUB