borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Select Statement (SQL Query))Next Topic (sql server 2000 stmt error) New Topic New Poll Post Reply
AndreaVB Forum : Database : Find command?
Poster Message
s1m0n
Level: Protégé

Registered: 09-10-2006
Posts: 4

icon Find command?

im using that code:

Private Sub cmdsignin_Click()

Dim User As String

User = Txtuser.Text

DE1.rsReg.Find "mname='" & User & "'"

    If DE1.rsReg.EOF Then
       MsgBox "user not found"
    End If

End Sub

im tryin to search for a name in data enviroment (access.mdb),
the prog always gives me user not found ny ideas?  

10-10-2006 at 08:55 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: Find command?

Try this :-

Dim User As String

User = Trim(Txtuser.Text)
DE1.rsReg.MoveFirst
DE1.rsReg.Find "([mname] Like '" & User & "')"

    If DE1.rsReg.EOF Then
       MsgBox "user not found"
    End If




____________________________
multi-tasking - the ability to hang more than one app. at the same time.

15-10-2006 at 09:37 AM
View Profile Send Email to User Show All Posts | Quote Reply
kckoshy
Level: Graduate

Registered: 12-09-2006
Posts: 9
icon Re: Find command?

Hi,
Here is a sample code. Please try it.

              'method 1
Private Sub cmdsignin_Click()
Dim User As String
User = Txtuser.Text
DE1.rsReg.Close
DE1.rsReg.Open "select * from ..... order by mname asc"
DE1.rsReg.MoveFirst
rs.Find "mname='" & user & "'"
If DE1.rsReg.EOF = False Then
' give the action to be done
exit sub
else
msg " no record "
End If
endsub

            method2

' in this it is asumed that your name field is in DE1.rsReg(1)
Private Sub cmdsignin_Click()
Dim User As String
User = Txtuser.Text
DE1.rsReg.Close
DE1.rsReg.Open "select * from ..... order by mname asc"
do while DE1.rsReg.eof = false
if DE1.rsReg(1)='" & user & "'" then
' give the action
DE1.rsReg.movenext
loop
endsub

'       method 3
' this option will work for fields that are indexed and are 'unique
Private Sub cmdsignin_Click()
Dim User As String
User = Txtuser.Text
DE1.rsReg.Open "select * from ..... where mname = '" & user &"' order by mname asc"
if de1.rsreg.eof = true then
msgbox " no such record"
else
' specifiy action
endif
endsub

' modification to your code
Private Sub cmdsignin_Click()
Dim User As String
User = Txtuser.Text
DE1.rsReg.Find "mname='" & User & "'"
    If DE1.rsReg.EOF = true Then
       MsgBox "user not found"
    End If
End Sub

".... give the table name "

bye have a good day



____________________________
kck

18-11-2006 at 04:31 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : Find command?
Previous Topic (Select Statement (SQL Query))Next Topic (sql server 2000 stmt error) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder