nondrinker
Programmer
I am working on a time punch program in MS Access.
The backend database is on SQLServer. The problem is that right now, the punch in and punch out times are taken from the machine that the user is working on. I am trying to make it take the time from the server where SQL database resides. Here is the code that i have right now when some body punches in:
*****************************************
Dim conDatabase As ADODB.Connection
Set conDatabase = CurrentProject.Connection
Dim strSQL3 As String
TimeIn = DateValue(Date) + TimeValue(Time)
SQLFields = SQLFields + "TimeIn"
SQLValues = SQLValues + "'" & TimeIn & "'"
strSQL3 = ("Insert into NewTimeData (" + SQLFields + "
values (" + SQLValues + "
"
conDatabase.Execute strSQL3
In this statement the TimeIn is from the system.
******************************************
To get the time from SQLServer, i am trying to execute this pass-through query from code.
"ServerTime" is the name of the query i have already in the Database objects and it runs on SQL server.
Dim ServerTimeValue, rs, ServerTime
Set rstEmployees2 = New ADODB.Recordset
rstEmployees2.Open "ServerTime", conDatabase, _
adOpenDynamic, adLockOptimistic
ServerTimeValue = rs("serverTime"
where serverTime is also the name of the column in the table.
But this one keeps giving me error. I am not even sure if this is the right way to execute a pass-through query in VBA code and then use the value (i.e. the variable ServerTimeValue) in the code.
Any suggestions??
Thanks.
The backend database is on SQLServer. The problem is that right now, the punch in and punch out times are taken from the machine that the user is working on. I am trying to make it take the time from the server where SQL database resides. Here is the code that i have right now when some body punches in:
*****************************************
Dim conDatabase As ADODB.Connection
Set conDatabase = CurrentProject.Connection
Dim strSQL3 As String
TimeIn = DateValue(Date) + TimeValue(Time)
SQLFields = SQLFields + "TimeIn"
SQLValues = SQLValues + "'" & TimeIn & "'"
strSQL3 = ("Insert into NewTimeData (" + SQLFields + "



conDatabase.Execute strSQL3
In this statement the TimeIn is from the system.
******************************************
To get the time from SQLServer, i am trying to execute this pass-through query from code.
"ServerTime" is the name of the query i have already in the Database objects and it runs on SQL server.
Dim ServerTimeValue, rs, ServerTime
Set rstEmployees2 = New ADODB.Recordset
rstEmployees2.Open "ServerTime", conDatabase, _
adOpenDynamic, adLockOptimistic
ServerTimeValue = rs("serverTime"

where serverTime is also the name of the column in the table.
But this one keeps giving me error. I am not even sure if this is the right way to execute a pass-through query in VBA code and then use the value (i.e. the variable ServerTimeValue) in the code.
Any suggestions??
Thanks.