Easy Problem with my code URGENT
Posted on 2005-05-12
Hi all, I cant seem to get round this even although its a very simple idea, what I am trying to do is search through a list of names and if there is more than one name then i need to another page with a flexgrid with full details of each of the names if there are more than one, but for simple sake, I just need it to show a text box. If there is only one name found then all i need is to show another text box. here is the code I am using, I have changed the requirements so that a msg box is shown if there is one name and another message is shown if there are more than one.
Private Sub CSearch(SCriteria)
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strIniFile As String
Dim found As Boolean
strIniFile = App.Path & "\dbconnectionstrings.ini"
conn.Provider = GetFromINI("ConnectionStrings", "sdmpr", strIniFile)
conn.Open GetFromINI("ConnectionStrings", "sdmdb", strIniFile)
sqlstr = "SELECT * FROM Clients ORDER BY Surname ASC"
rs.Open sqlstr, conn, adOpenKeyset, adLockOptimistic
If cmbsearch.Text = "" Then
MsgBox "Please select a field to search", vbintormation, "Define Search Field"
criteria = cmbsearch.Text
Do Until .EOF Or found
If .Fields(criteria) = SCriteria Then
counter = counter + 1
found = true <<< I know this will stop the loop here, but just an idea of what im trying to get.
If counter > 1 Then
MsgBox "found more than one name"
If found = True Then
MsgBox "Found one name"
MsgBox "Record not found", vbInformation, "Record Search"
Set rs = Nothing
Set conn = Nothing