Well, without the structure, and with a few minutes to spare, here are the steps:
For the on click event of the submit button, collect the worker's ID number from your form, something like this:
'--------------------
Dim intWorker As Integer
intWorker = Me.WorkerID 'assumes there is a field with this name
'--------------------
Then call your SQL server, either using an installed DSN, or some other method, something like:
'--------------------
Dim strUserName As String
Dim strPassword As String
Dim strSQL As String
strUserName = "YourUserName"
strPassword = "YourPassword"
strSQL = "SELECT * FROM tblYourTable WHERE [WorkerID] = " & intWorker
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=YourDSN;", strUserName, strPassword
objRecordset.CursorLocation = adUseClient
objRecordset.Open strSQL, objConnection, adOpenStatic, adLockOptimistic
'-------------------------
Then check the field containing the Wage value something like:
'------------------------
If IsNull objRecordset.Fields(4) Then 'assumes wage is the fifth field
intWage = 0
Else
intWage = objRecordset.Fields(4)
End If
'------------------------
Then send a message based on this value.
If it is 0, then cancel the update, open the proper form to enter a wage, filtered for the Worker in question, and cancel the update.
Then on the on click event of the wage form, refresh the first form, and allow them to try the update again.
That was easy. :D
HTH
mmcdonal
|