Results 1 to 2 of 2
  1. #1
    jj1 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    128

    Popup shows up asking for ID

    I am getting 2 problems what I am trying to do is depending on the user loging in I want to open form (Aform) on specific record for that person ID. However where Y=1 I am getting a popup asking for AForm ID and where Y=2 I am getting run time error 3075 Syntax error (missing operator) in query expression.
    Code:
    Private Sub Command6_Click()
     
     If IsNull(txtUsername) Then
        MsgBox "Invalid username"
        Exit Sub
    End If
    If IsNull(txtPassword) Then
        MsgBox "Invalid password"
        Exit Sub
    End If
     
    Dim X As Long
    Dim SQL As String
    X = Nz(DLookup("UserID", "UserT", "Username='" & txtUsername & "' AND Password='" & txtPassword & "'"))
    'MsgBox "" & X & ""
    If X > 0 Then
        Dim Y As Long
        Y = Nz(DLookup("GroupID", "GroupXUsersT", "UserID='" & X & "'"))
        
        'MsgBox "" & Y & ""
        'We have a valid user
        If Y = 1 Then
            DoCmd.OpenForm "MainMenu"
            DoCmd.OpenForm "AForm", acNormal, , "[AID] = " & txtUsername
            Forms!MainMenu!txtUserID = X
            Forms!MainMenu!txtUsername = txtUsername
            Forms!AForm!txtUserID = X
            Forms!AForm!txtUsername = txtUsername
            DoCmd.Close acForm, "LoginF"
        End If
       If Y = 2 Then
            DoCmd.OpenForm "MainMenu"
            DoCmd.OpenForm "NewHireFeedbackForm", acNormal, , "[NewHireID] = " & txtUsername
            Forms!MainMenu!txtUserID = X
            Forms!MainMenu!txtUsername = txtUsername
            Forms!NewHireFeedbackForm!txtUserID = X
            Forms!NewHireFeedbackForm!txtUsername = txtUsername
            DoCmd.Close acForm, "LoginF"
        End If
    Else
        MsgBox "Invalid Logon"
    End If
        
    End Sub


  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,642
    Are AID and UserID and NewHireID all text type fields?

    If they are, then must use apostrophe delimiters in filter criteria - as you have for opening AForm. If they are number type, don't use any delimiters.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Why does this table popup?
    By twillingham in forum Access
    Replies: 3
    Last Post: 09-22-2014, 07:15 AM
  2. Popup form
    By marcsessoms in forum Forms
    Replies: 8
    Last Post: 02-17-2012, 08:53 PM
  3. Popup notification
    By imintrouble in forum Queries
    Replies: 1
    Last Post: 01-19-2012, 03:28 PM
  4. Popup on open
    By imintrouble in forum Forms
    Replies: 2
    Last Post: 09-30-2011, 03:20 PM
  5. Popup Should come before insert
    By waqas in forum Forms
    Replies: 1
    Last Post: 09-22-2011, 12: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