Results 1 to 9 of 9

Thread: Comparing numbers with DAO database **RESOLVED**

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419

    Comparing numbers with DAO database **RESOLVED**

    Hello, I am making a program that has a feature that will read a field in an access file (the field is called "Ratio"). I am wondering how I would go about when I perform the
    Data1.Recordset.MoveNext, it will compare the number in "txtRatio.text" to all the numbers in the "Ratio" column for each record. If the Ratio is within +/- 10%, list them in a listbox.
    Last edited by LostAngel; Sep 27th, 2003 at 11:32 PM.
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

  2. #2
    Addicted Member
    Join Date
    Sep 2003
    Posts
    160
    you may definately need to open another recordset to same table and put some code like this in data1 reposition event

    With data2.Recordset
    .MoveFirst
    Do While .EOF = False
    tRatio = .Fields("Ratio")
    sRatio = Data1.Fields("Ratio")
    If tRatio >= sRatio Then
    If (tRatio - sRatio) <= 10 Then
    List1.AddItem tRatio
    End If
    ElseIf tRatio < sRatio Then
    If (sRatio - tRatio) < 10 Then
    List1.AddItem tRatio
    End If
    End If
    Loop
    End With

    by the way don't forget to put filter DATA2 to skip loading current selected recordset in Data1.

    Hope it helps
    S. Mohammad Najafi

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419
    Thank you for your reply, but I am still a little confused...
    Would you possibly be able when you get time to make a small example program ? I would greatly appreciate it. I am still rather new at databases.
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

  4. #4
    Addicted Member
    Join Date
    Sep 2003
    Posts
    160
    there you are and I hope it helps you out
    S. Mohammad Najafi
    Attached Files Attached Files

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419
    Hello, what would I do to convert this program to DAO? This is the type that I have been using in the rest of my program. Also, when I tried to run the program it came up with an error: DBconn.CursorLocation = adUseClient.
    Is it hard to convert to DAO?
    Last edited by LostAngel; Sep 27th, 2003 at 01:29 PM.
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

  6. #6
    Addicted Member
    Join Date
    Sep 2003
    Posts
    160
    what ado version you're using ? get the latest one and latest VB Service pack 5 and I would recommend you move to ADO because DAO doesn't support link to same table twice and you have to do alot of tricks to and query stuff to do that... you remove cursorlocation for now and see if its work

    Hope it helps.
    S. Mohammad Najafi

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419
    I am currently downloading MDAC 2.8, I will tell you if it works when it's done. Thanks for your advice on using ADO.
    *REVISED*
    Thank you very much, The program now works without any problems. Will it be that hard for me to go from DAO to ADO seeings I am used to DAO?
    Last edited by LostAngel; Sep 27th, 2003 at 06:26 PM.
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

  8. #8
    Addicted Member
    Join Date
    Sep 2003
    Posts
    160
    not at all. you just have to re-set your connection stuff the rest is almost like ado

    S. Mohammad Najafi

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419
    Thank you, I have been tinkering with it and I find it is easy. Thanks again for your help and example.
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

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