3 Replies - 542 Views - Last Post: 17 November 2012 - 09:15 AM Rate Topic: -----

#1 lamsen  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 13
  • Joined: 21-September 12

question about find with where

Posted 14 November 2012 - 05:35 AM

hello everyone
i need to find a specific "brandname" of a "vehicletype" if it is exist before I add a new brand,
its my first time to use ".find" function with "where" i dont know if this is right

with rsbrands
    .Find "BrandName='" & Text5.Text & "'" where VehicleType='" & Combo4.Text & "'", 0, adSearchForward, adBookmarkFirst
        If (.EOF = False) Then
            MsgBox "That Brand already exist!", vbInformation, " "
        else
        'add code
        end if
end with



check my code please.
thank you :)

Is This A Good Question/Topic? 0
  • +

Replies To: question about find with where

#2 lamsen  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 13
  • Joined: 21-September 12

Re: question about find with where

Posted 14 November 2012 - 08:08 AM

already solve my problem, i used "open" before "find"
for those who have the same problem here's what i do

Dim rs As New ADODB.Recordset
rs.Open "select BrandName from Brands where VehicleID='" & text7.Text & "'", cn, adOpenStatic, adLockReadOnly
        While rs.EOF = False
        rs.Find "BrandName ='" & Text5.Text & "'", 0, adSearchForward, adBookmarkFirst
        If rs.EOF = False Then
            MsgBox "That Brand already exist!", vbInformation, " "
            Text5.Text = ""
            Text5.SetFocus
        else
            'my add code
        end if
        wend



hope this will be useful
Was This Post Helpful? 2
  • +
  • -

#3 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: question about find with where

Posted 14 November 2012 - 08:32 AM

Well done on solving the problem and thanks for posting the solution for the benefit of others.
Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 572
  • View blog
  • Posts: 2,985
  • Joined: 19-May 09

Re: question about find with where

Posted 17 November 2012 - 09:15 AM

One little point: your if statement will always be true, because you'll only encounter it while eof is false. So you don't need it. Right?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1