|
-
May 20th, 2005, 10:09 AM
#1
Checking Horizontally and vertically using ADO?
For the record, i am using ADODB, with VBA in MS Access 2002
Current Code:
VB Code:
Private Sub personCalculations()
'*******************************************************
'Opens the database and then opens the Workers table
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\TSmith14\Desktop\test.mdb"
cn.Open
Set rs = New ADODB.Recordset
rs.Open "Workers", cn, adOpenKeyset, adLockPessimistic, adCmdTable
'********************************************************
Do While rs.EOF = False
'********************************************************
'Finds the academic payamount by comparing Current Payband from the
'Workers table, to the salary with the payband located in AcademicPayband
If rs.Fields("Group") = "Academic" Then
Set RsPayband = New ADODB.Recordset
RsPayband.Open "AcademicPayband", cn, adOpenKeyset, adLockPessimistic, adCmdTable
Do While RsPayband.EOF = False
If RsPayband.Fields("Payband") = rs.Fields("Current Payband") Then
academictotals = academictotals + RsPayband.Fields("Salary")
End If
RsPayband.MoveNext
Loop
RsPayband.Close
'**********************************************************
ElseIf rs.Fields("Group") = "Support" Then
Set RsPayband = New ADODB.Recordset
RsPayband.Open "Support Paybands", cn, adOpenKeyset, adLockPessimistic, adCmdTable
Do While RsPayband.EOF = False
Loop
RsPayband.Close
End If
rs.MoveNext
Loop
rs.Close
Label8.Caption = academictotals
'********************************************************
End Sub
Okay, well the academicpayband can find the values very easily, because it is just going through the file in sequential order, but now I am trying to do supportpayband, in which i need to deal with a database like this
VB Code:
Fields: Payband, Level1, Level2, Level3, Level4, Level5, Level6
1 $##.## $##.## $##.## $##.## $##.## $##.##
2 $##.## $##.## $##.## $##.## $##.## $##.##
3 $##.## $##.## $##.## $##.## $##.## $##.##
4 $##.## $##.## $##.## $##.## $##.## $##.##
5 $##.## $##.## $##.## $##.## $##.## $##.##
***Sorry for the messy table, but I cant seem to get it right >.<***
Now I need to go through, match the payband, then, match the level, and grab the corresponding value ($##.##) from the table.
I have done multiple attempts at this, but it never seems to grab the value I want.
Could anyone give me some hints on this?
Last edited by kfcSmitty; May 20th, 2005 at 10:21 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|