Results 1 to 4 of 4
  1. #1
    Batselot is offline Novice
    Windows 8 Access 2016
    Join Date
    Aug 2018
    Posts
    14

    VBA login screen

    Hello there everyone, I have done a login screen with a video I have found on youtube but my code seems to have errors or an error.
    Private Sub btnLogin_Click()


    Dim rs As Recordset

    Set rs = CurrentDb.OpenRecordset("Info", dbOpenSnapshot, dbReadOnly)

    rs.FindFirst "Username='", Me.txtUserName, "'"
    If rs.NoMatch = True Then
    Me.lblWrongUser.Visible = True
    Me.txtUserName.SetFocus
    Exit Sub
    End If
    Me.lblWrongUser.Visible = False

    If rs!Password <> Nz(Me.txtPassword, "") Then
    Me.LblWrongPassword.Visible
    Me.txtPassword.SetFocus
    Exit Sub
    End If
    Me.LblWrongPassword.Visible = False
    DoCmd.OpenForm "Liste"
    DoCmd.Close acForm, Me.Name
    End Sub

    This is the code I used for the login screen but when I tell it to run it gives me "Compile error: Wrong number of arguments or invalid property assignment.I can't seem to get what is wrong with it although rs.FindFirst is flashing blue.I would appreciate any help thanks.

  2. #2
    isladogs's Avatar
    isladogs is offline Very idle programmer
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    4,196
    Was the YouTube video for VBA in Access?

    As a starting point use
    1. Dim rs as DAO.Recordset
    2. Replace the two commas in the Set rs line with a space followed by an ampersand ' &'

    There may be other issues but hopefully that's enough to fix it
    Colin (Mendip Data Systems) : Website, email
    If this has helped, please click the star button and leave a comment

  3. #3
    Batselot is offline Novice
    Windows 8 Access 2016
    Join Date
    Aug 2018
    Posts
    14
    Thanks a lot it helped me fix the problem, also later in the video i noticed it was an ampersand but since it was low quality i saw it as an comma thanks again

  4. #4
    isladogs's Avatar
    isladogs is offline Very idle programmer
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    4,196
    You're welcome.
    There are plenty of high resolution videos on YouTube. Try those by Steve Bishop or Richard Rost.
    Colin (Mendip Data Systems) : Website, email
    If this has helped, please click the star button and leave a comment

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Creating a Classic Login Screen
    By Xipooo in forum Tutorials
    Replies: 1
    Last Post: 02-03-2016, 07:02 AM
  2. LogIn Screen
    By Bongobob21 in forum Forms
    Replies: 2
    Last Post: 05-18-2015, 08:28 AM
  3. Login in form - not showing on screen
    By Sheba in forum Forms
    Replies: 2
    Last Post: 10-08-2014, 09:57 AM
  4. Login Screen in Access
    By Di7bash in forum Access
    Replies: 3
    Last Post: 03-18-2014, 11:57 PM
  5. Login screen coding
    By thinkkwise in forum Access
    Replies: 1
    Last Post: 08-05-2013, 05:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums