seek method 
Author Message
 seek method

I have this code:

Set db = CurrentDb
Set Rst = db.OpenRecordset("tbl_buy_in", dbOpenTable)
    Rst.Index = "ProjectID"
    Rst.Seek "=", strPrjNo
        If Rst.NoMatch = True Then
            Me.cboBuy_In.Visible = False
        Else
            Me.cboBuy_In.Visible = True
        End If
    Rst.Close

I have another criteria that needs to be matched as well as the projectID
(it's called strLink).  Is that possible?  So -I need to see if there is a
match based on the projectID and Link criteria.

TIA!
Daya



Sat, 18 Dec 2004 06:43:37 GMT  
 seek method

Quote:

>I have this code:

>Set db = CurrentDb
>Set Rst = db.OpenRecordset("tbl_buy_in", dbOpenTable)
>    Rst.Index = "ProjectID"
>    Rst.Seek "=", strPrjNo
>        If Rst.NoMatch = True Then
>            Me.cboBuy_In.Visible = False
>        Else
>            Me.cboBuy_In.Visible = True
>        End If
>    Rst.Close

>I have another criteria that needs to be matched as well as the projectID
>(it's called strLink).  Is that possible?  So -I need to see if there is a
>match based on the projectID and Link criteria.

Seek only works with a single index.  If it's a multi-field
index then you can specify both fields (see Help for
details).

The common technique is to open the recordset as a dynaset
and then use FindFirst.  FindFirst allows you to use a Where
clause (without the word where) that may include many
conditions separated by And or Or.

Set Rst = db.OpenRecordset("tbl_buy_in", dbOpenDynaset)
        Rst.FindFirst "ProjectID = " & strPrjNo _
                                & " And Link = " & somevalue
         If Rst.NoMatch = True Then

FindFirst is often much slower than Seek, but it is more
flexible.

--
Marsh
MVP [MS Access]



Sat, 18 Dec 2004 07:20:01 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. SEEK Method/FindFirst Methods

2. Seek Method isn't working...

3. SEEK method w/truncated criteria

4. Field Name in Seek Method

5. Linked tables and the seek method

6. case sensitivity with seek method

7. Using Seek Method in VB6

8. Understanding the SEEK Method

9. SEEK Method ... Advanced Question

10. Seek method not working in 7.0 from 2.0

11. Seek method for multiple records?

12. ***** SEEK METHOD ******

 

 
Powered by phpBB® Forum Software