Hi guys.
I’m not familiar with Ms access VB (or any other for that matter)but learning fast. I have tried various methods to achieve the outcome but all have failed.
Background
Front End developed using MS Access Forms which is connected to SQL Server 2005 DB. Allowing users to capture Customer info.
Objective
On value input in on the form it needs to make reference to a scorecard (on db), check the input against the scorecard variables and once matched the points associated with the value to be written to another table in db.
I’m hoping I’m not confusing the matter.
Below is one attempt(failed horribly). Don’t have any idea of how to resolve or achieve the outcome. Would appreciate any assistance
I’m not familiar with Ms access VB (or any other for that matter)but learning fast. I have tried various methods to achieve the outcome but all have failed.
Background
Front End developed using MS Access Forms which is connected to SQL Server 2005 DB. Allowing users to capture Customer info.
Objective
On value input in on the form it needs to make reference to a scorecard (on db), check the input against the scorecard variables and once matched the points associated with the value to be written to another table in db.
I’m hoping I’m not confusing the matter.
Below is one attempt(failed horribly). Don’t have any idea of how to resolve or achieve the outcome. Would appreciate any assistance
Code:
Private Sub Form_AfterUpdate()
Dim db As DAO.Database
Dim SC As DAO.Recordset
Dim OutPut As DAO.Recordset
Dim Value As Integer
Set db = CurrentDb()
Set SC = db.OpenRecordset("dbo_BBRS_SC", dbOpenSnapshot)
Set OutPut = db.OpenRecordset("dbo_Cust_RG_Scr_Values", dbOpenSnapshot, dbSeeChanges)
Value = Customer!CB_Industry
If SC.RecordCount = 0 Then Exit Sub
SC.MoveFirst
' loop through each record in the first recordset
Do Until SC.RecordCount = 11 Or ctr > 11
If Value = SC!ID_LKVar Then
OutPut.AddNew
OutPut![Score] = SC![Score]
OutPut.Update
Else
If Value <> SC!ID_LKVar Then
OutPut.AddNew
OutPut![Score] = 99
OutPut.Update
End If
ctr = ctr + 1
Loop
SC.Close
OutPut.Close
Set SC = Nothing
Set OutPut = Nothing
Set db = Nothing
End If
End Sub
Comment