Results 1 to 2 of 2

Thread: Checking Horizontally and vertically using ADO?

Threaded View

  1. #1

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Checking Horizontally and vertically using ADO?

    For the record, i am using ADODB, with VBA in MS Access 2002

    Current Code:

    VB Code:
    1. Private Sub personCalculations()
    2. '*******************************************************
    3. 'Opens the database and then opens the Workers table
    4. Set cn = New ADODB.Connection
    5. cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    6.       "Data Source=C:\Documents and Settings\TSmith14\Desktop\test.mdb"
    7.     cn.Open
    8.     Set rs = New ADODB.Recordset
    9.     rs.Open "Workers", cn, adOpenKeyset, adLockPessimistic, adCmdTable
    10. '********************************************************
    11. Do While rs.EOF = False
    12. '********************************************************
    13. 'Finds the academic payamount by comparing Current Payband from the
    14. 'Workers table, to the salary with the payband located in AcademicPayband
    15. If rs.Fields("Group") = "Academic" Then
    16.     Set RsPayband = New ADODB.Recordset
    17.     RsPayband.Open "AcademicPayband", cn, adOpenKeyset, adLockPessimistic, adCmdTable
    18.     Do While RsPayband.EOF = False
    19.     If RsPayband.Fields("Payband") = rs.Fields("Current Payband") Then
    20.     academictotals = academictotals + RsPayband.Fields("Salary")
    21.     End If
    22.     RsPayband.MoveNext
    23.     Loop
    24.     RsPayband.Close
    25. '**********************************************************
    26. ElseIf rs.Fields("Group") = "Support" Then
    27.     Set RsPayband = New ADODB.Recordset
    28.     RsPayband.Open "Support Paybands", cn, adOpenKeyset, adLockPessimistic, adCmdTable
    29.     Do While RsPayband.EOF = False
    30.    
    31.     Loop
    32.     RsPayband.Close
    33.    
    34. End If
    35. rs.MoveNext
    36. Loop
    37. rs.Close
    38. Label8.Caption = academictotals
    39. '********************************************************
    40.    
    41. 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:
    1. Fields:  Payband,      Level1,      Level2,       Level3,      Level4,       Level5,    Level6
    2.              1         $##.##       $##.##        $##.##      $##.##         $##.##    $##.##
    3.              2         $##.##       $##.##        $##.##      $##.##         $##.##    $##.##        
    4.              3         $##.##       $##.##        $##.##      $##.##         $##.##    $##.##
    5.              4         $##.##       $##.##        $##.##      $##.##         $##.##    $##.##
    6.              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
  •  



Click Here to Expand Forum to Full Width