|
-
Dec 5th, 2000, 01:33 PM
#1
Thread Starter
Member
whats wrong with this code???
Set rs = Db.OpenRecordset("SELECT * FROM MyNames")
With rs Do
strFind = "Name='Bjorn'"
rs.FindFirst strFind
If Not .NoMatch Then
i = i + 1
Do Until .NoMatch
rs.FindNext strFind
i = i + 1
Debug.Print .Name & ", " & i & " records found!"
Loop
Else
MsgBox "No name found"
End If
Loop
if i have 2 names that are the same and if i search at the name that are 2 times in my database how can i get that 2 persons ore more
-
Dec 6th, 2000, 03:18 AM
#2
Lively Member
Why don't you use this one, I think it's a bit more simple :
Dim strFind As String
Dim rs As Recordset
strFind = "bjorn"
Set rs = Db.OpenRecordset("SELECT * FROM MyNames WHERE (Name=""" & strFind & """);")
If rs.BOF And rs.EOF _
Then
Beep
MsgBox "No name found"
Else
rs.MoveLast
rs.MoveFirst
Beep
MsgBox "A number of " & rs.RecordCount & " records were found"
End If
rs.Close
-
Dec 6th, 2000, 03:55 AM
#3
Fanatic Member
Try this ...
Code:
strFind = "bjorn"
strSQL = "SELECT COUNT(*) AS TotalCount " & _
"FROM MyNames " & _
"WHERE Name = '" & strFind & "'"
Set rs = db.OpenRecordset(strSQL)
MsgBox "Records Found : " & rs!TotalCount
rs.Close
Set rs = Nothing
VB6 sp5, SQL Server 2000, C#
There are no stupid questions. Only stupid people. 
-
Dec 6th, 2000, 07:36 AM
#4
Thread Starter
Member
Yes but i want to out but the names from it
like if i have to bjorn in my database i wanne output it on a textbox for example thats all
-
Dec 6th, 2000, 08:15 AM
#5
Fanatic Member
Bjorn,
Your original code looks OK except you have one Do and two Loops, one With and no End With.
Replace the last 'Loop' with 'End With'.
Are you sure it compiles?
P.
Not nearly so tired now...
Haven't been around much so be gentle...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|