HI have an app in access 2007, trying to modify the code to connect it to sql 2008.
I have a form with a subform.
The employeeID is in the form and Subform has employee's tasks. the relationship is from form to subform one to many.(employee table to task table)
initially application was not connected to sql server and code below was used:
there is a code which checks if a task has already been asigned to the employee and if it is generate message.
private sub cmb_task_beforeupdate(cancel as integer)
dim rst recordset
dim sql as string
dim ind as integer
sql = select taskxxx.[employeeid] from task where (((taskxxx.[employeeid])=" &parent![employeeid] & ") and (( taskxxx.[taskid]) ='" & me.cmb_task & "'));"
set rst = currentdb.openrecordset(sql,dbopensnapshot)
ind = rst.recordCount
if ind > 0 then
cancel = 1
now that I am connected to sql server I changed the sql =
statement above to:
sql = select task.employeeid,task.id from task where task.employeeid = " & parent![parent_id] & ") and (( task.id)='" & me.cmb_task & "'));"
I am not familiar with access snapshot,.... all I need is to check if select statement returns any value and then cancel addition of tasks.
how can I fix above code in vba?