tendaimare's Profile User Rating: -----

Reputation: 1 Apprentice
Group:
Active Members
Active Posts:
170 (0.12 per day)
Joined:
04-November 10
Profile Views:
2,396
Last Active:
User is offline Oct 23 2013 01:41 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   tendaimare has not set their status

Posts I've Made

  1. In Topic: search not returning accurate values

    Posted 18 Jun 2013

    View PostBobRodes, on 11 June 2013 - 03:11 AM, said:

    Your problem is that you are confusing two different concepts and your thinking has therefore become disorganized. Now pay attention. :)/>/>

    If BOTH BOF and EOF are true, then your recordset is empty (you've gone beyond the beginning and beyond the end of the data both at once). On the other hand, if you call the Find method, and the value you're looking for isn't there, then you'll run past the end of the recordset and EOF will be true. BUT BOF won't; you've only gone beyond the end of the data.

    So, let's backtrack to your first code sample. After line 4, you want to check and see if there are any records to find. So check both BOF and EOF and return false if both are true. After line 5, you want to see if a record got found (you don't need the additional step of first checking if the record you're on is a match; find will stop there if it is). If EOF is true, then it didn't. So, here, you check for EOF but NOT BOF.

    Your main problem is your line 6 should only check BOF.

    By the way, I prefer using Filter to using Find, personally:
    
    '[open a recordset called rs]
    '[create strCriteria]
    with rs
       .Filter = strCriteria
       CheckIfSupplyWhateverIsValid = Not(.BOF And .EOF)
    End With
    
    

    As you can see, there's a lot less drama.


    BobRodes you're RIGHT the code worked well.You're the best, but I am still using Find This is the final code. I'll try out the Filter. Thanks!!!
    Private Function CheckIfCustomerTypeIsValid() As Boolean
        strCriteria = "Type=" & " '" & Trim(DataComboCustomerType.Text) & "' "
        Set rstCustomers = New ADODB.Recordset
        rstCustomers.Open "CustomerTypeOfAccounts", Cnn, adOpenDynamic, , adCmdTable
        rstCustomers.Find strCriteria
        If (rstCustomers.EOF = True) Or (rstCustomers.BOF = True) Then
        CheckIfCustomerTypeIsValid = False
        Else
        CheckIfCustomerTypeIsValid = True
        End If
     End Function
    
    
  2. In Topic: msgbox issue

    Posted 12 Jun 2013

    I have a main form right, it comes up as a result of a simple mainform.show. The I have form1 which also comes up as a result of form1.show. But when I run the msgbox function. The form1 disappears leaving the messagebox on top of the mainform in modal form. When I respond to the message box by saying OK (or something else) then the form1 shows up. This behavior is the one I want to run away from.

    If I run form1 in Modal view the message box will show up on top of form1, without form1 disappearing.
  3. In Topic: search not returning accurate values

    Posted 4 Jun 2013

    I am still getting the same error. But I was not sure about where exactly to put the find statement.

    
     Private Function CheckIfSupplierTypeIsValid() As Boolean
        strCriteria = "TruckType=" & " '" & Trim(DataComboSupplierType.Text) & "' "
        Set rst = New ADODB.Recordset
        rst.Open "TruckTypes", Cnn, adOpenForwardOnly, , adCmdTable
        
        If rst.BOF And rst.EOF Then
           CheckIfSupplierTypeIsValid = False
        End If
       rst.Find strCriteria, 1, adSearchForward
        If Trim(DataComboSupplierType.Text) = rst!TruckType Then
            CheckIfSupplierTypeIsValid = True
        Else
         rst.Find strCriteria, 1, adSearchForward
            CheckIfSupplierTypeIsValid = True
        End If
     End Function
    
    
    
    
  4. In Topic: search not returning accurate values

    Posted 4 Jun 2013

    The elseif line
     Private Function CheckIfSupplierTypeIsValid() As Boolean
        strCriteria = "TruckType=" & " '" & Trim(DataComboSupplierType.Text) & "' "
        Set rst = New ADODB.Recordset
        rst.Open "TruckTypes", Cnn, adOpenForwardOnly, , adCmdTable
        rst.Find strCriteria, 1, adSearchForward
        If rst.BOF And rst.EOF Then
           CheckIfSupplierTypeIsValid = False
        ElseIf rst!TruckType = Trim(DataComboSupplierType.Text) Then
            CheckIfSupplierTypeIsValid = True
        Else
            CheckIfSupplierTypeIsValid = True
        End If
     End Function
    
    
  5. In Topic: search not returning accurate values

    Posted 4 Jun 2013

    Okay Sir, I tried but now I am getting an error that says "Either EOF and BOF is true, or the current record has been deleted.Requested operation requires a current record."

    
     Private Function CheckIfSupplierTypeIsValid() As Boolean
        strCriteria = "TruckType=" & " '" & Trim(DataComboSupplierType.Text) & "' "
        Set rst = New ADODB.Recordset
        rst.Open "TruckTypes", Cnn, adOpenForwardOnly, , adCmdTable
        rst.Find strCriteria, 1, adSearchForward
        If rst.BOF And rst.EOF Then
           CheckIfSupplierTypeIsValid = False
        ElseIf rst!TruckType = Trim(DataComboSupplierType.Text) Then
            CheckIfSupplierTypeIsValid = True
        Else
            CheckIfSupplierTypeIsValid = True
        End If
     End Function
    
    
    
    

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Comments

tendaimare has no profile comments yet. Why not say hello?