Newbie Question about FindRecord Method 
Author Message
 Newbie Question about FindRecord Method

I have a form which has a search routine in it and I'm trying to find
out if there is some code which will tell me if I get a match or not
with the following DoCmd statement. I've searched through the help files
and can't find anything that seems to fit.

Dim txtX as String
txtX = a specific value
DoCmd.FindRecord txt_net_search, acEntire, False, acSearchAll, False,
acCurrent, True

'The above part works fine but I'm trying to determine if the find
routine returns a match or not.

Can anyone help ?



Tue, 01 Jul 2003 12:33:47 GMT  
 Newbie Question about FindRecord Method
If you're attempting to determine whether a record exists with a
particular value use a recordset and an SQL statement.

psuedo code:

dim dbs as database
dim rst as recordset
dim txtsql as string
' if you are passing a value you will not need this...
dim txtX as string
txtX = a specific value

set dbs = currentdb()
' build sql statement
txtSQL = select * from <InsertTableName> Where <InsertFieldName> = " _
        & Chr$(34) & txtX &  Chr$(34)
set rst = dbs.openrecordset
if rst.Recordset > 0 then
        ' we have at least one record
end if

Steve


Quote:
>I have a form which has a search routine in it and I'm trying to find
>out if there is some code which will tell me if I get a match or not
>with the following DoCmd statement. I've searched through the help files
>and can't find anything that seems to fit.

>Dim txtX as String
>txtX = a specific value
>DoCmd.FindRecord txt_net_search, acEntire, False, acSearchAll, False,
>acCurrent, True

>'The above part works fine but I'm trying to determine if the find
>routine returns a match or not.

>Can anyone help ?



Wed, 02 Jul 2003 02:04:15 GMT  
 Newbie Question about FindRecord Method

Thanks Steve, I couldn't get your suggested code to work with the Chr$(34) in
it ?? But when I adjusted the sql statement to the following (I put my
changes in bold) it worked just fine.

txtSQL = "select * from <InsertTableName> Where <InsertFieldName> = " _
        '" & txtX &  '";"
set rst = dbs.openrecordset
if rst.RecordCount > 0 then

Is Chr$(34) doing the same thing ?

Quote:

> If you're attempting to determine whether a record exists with a
> particular value use a recordset and an SQL statement.

> psuedo code:

> dim dbs as database
> dim rst as recordset
> dim txtsql as string
> ' if you are passing a value you will not need this...
> dim txtX as string
> txtX = a specific value

> set dbs = currentdb()
> ' build sql statement
> txtSQL = select * from <InsertTableName> Where <InsertFieldName> = " _
>         & Chr$(34) & txtX &  Chr$(34)
> set rst = dbs.openrecordset
> if rst.Recordset > 0 then
>         ' we have at least one record
> end if

> Steve


> >I have a form which has a search routine in it and I'm trying to find
> >out if there is some code which will tell me if I get a match or not
> >with the following DoCmd statement. I've searched through the help files
> >and can't find anything that seems to fit.

> >Dim txtX as String
> >txtX = a specific value
> >DoCmd.FindRecord txt_net_search, acEntire, False, acSearchAll, False,
> >acCurrent, True

> >'The above part works fine but I'm trying to determine if the find
> >routine returns a match or not.

> >Can anyone help ?



Thu, 03 Jul 2003 02:46:15 GMT  
 Newbie Question about FindRecord Method


Quote:
>Thanks Steve, I couldn't get your suggested code to work with the Chr$(34) in
>it ?? But when I adjusted the sql statement to the following (I put my
>changes in bold) it worked just fine.

>txtSQL = "select * from <InsertTableName> Where <InsertFieldName> = " _
>        '" & txtX &  '";"
>set rst = dbs.openrecordset
>if rst.RecordCount > 0 then

>Is Chr$(34) doing the same thing ?

Chr$(34) translates to a double-quote " in the SQL string...

Steve



Sat, 05 Jul 2003 07:30:47 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Problems using CommandBarComboBox as search criteria for FindRecord method

2. Need Help with FindRecord Method

3. Newbie attempting to use DoCmd.FindRecord w/ VB5

4. FindRecord Question

5. Calling a method in a vb dll from html page - newbie question

6. Maybe a newbie question : Howto have a timeout on a COM Object method call

7. using wildcards with seek method (Newbie Question)

8. FindRecord

9. If Not Found Then: FindRecord code in DAO/ADO

10. FindRecord

11. Using FindRecord in a combo box

12. Using FindRecord

 

 
Powered by phpBB® Forum Software