Hello, I was wondering how you would make this work, I have a user name and an ID, I want them to be contacted so when the user inputs there name the user ID will be found and appear on the form in its box, I am using access. Thankyou :)
Printable View
Hello, I was wondering how you would make this work, I have a user name and an ID, I want them to be contacted so when the user inputs there name the user ID will be found and appear on the form in its box, I am using access. Thankyou :)
ok this is what i have so far,
i am trying to find if the username exists then i have this on a button,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 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.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
do you want to fetch the user id based on the user name entered
I dont see u merging any fields of access. You are just trying to compare values in a field and pop up the related value into a label/textbox for this you may have to use rs.find method. you appear also to be in wrong forum ask mod to move u to classic VB, or Visual basic. Also make a search for autocomplete textbox in Classic VB which can make u keep going.