Results 1 to 4 of 4

Thread: Merging two data fields using access??

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Cool Merging two data fields using access??

    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

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Merging two data fields using access??

    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.

  3. #3
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Merging two data fields using access??

    do you want to fetch the user id based on the user name entered
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  4. #4
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Merging two data fields using access??

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width