ok this is what i have so far,
Code:
Public Function UsernameExists(number As String) As Boolean
' declarations
Dim rst As New ADODB.Recordset 'create recordset object
Dim intMaxRecs As Integer
Dim nameFound As Boolean
Dim intCount As Integer
nameFound = False
' open the db
rst.Open "SELECT username.text FROM AddComments;", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
' find how many records
intMaxRecs = rst.RecordCount
' cycle through and see if it exists within the DB
rst.MoveLast
rst.MoveFirst
For intCount = 1 To intMaxRecs
If (Name = rst("text").Value) Then
nameFound = True
End If
rst.MoveNext
Next intCount
' close the Database
rst.Close
If (nameFound) Then
nameExists = True
Else
nameExists = False
End If
End Function
i am trying to find if the username exists then i have this on a button,
Code:
Dim strUserName As String
Dim intUserName As Double
strUserName = InputBox("Please enter username")
intUserName = Val(strUserName)
If (intUserName <> 0) Then
If (UsernameExists(strUserName)) Then
MsgBox "user name exists.", vbCritical, "Error"
End If
Else
MsgBox "please sign up.", vbCritical, "Error"
End If
End Sub
i want the code to search the databse and find then user name, once it done that i want it to find the userID for theat name, i think i am on the right lines with this, but not sure, any help i woul be thankful for.