#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2012
    Posts
    18
    Rep Power
    0

    ms Access Macro Help


    i tried using macro to locate it but doesn't work.
    After logging in from "Login" Form it will open up a form "LoginMenu" with a list of buttons of Forms that i'm able to access to.

    This Macro is in "LoginMenu" with a list of buttons of macro events
    If [Forms]![Login]![cboUsername]="Admin" Then
    Open Form
    Form name: Club
    View: Form
    Data Mode: Read Only
    Window mode: normal
    End if

    and after i try logging in to admin and click Clubs

    Error: Microsoft Access cannot find referenced form "Login"

    i don't understand why it can't find the form when it's located together there...
  2. #2
  3. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Jun 2011
    Location
    South Jersey
    Posts
    544
    Rep Power
    59
    Can you post the code you are using to open the form [LoginMenu]?
  4. #3
  5. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2012
    Posts
    18
    Rep Power
    0
    Originally Posted by meratigoerr
    Can you post the code you are using to open the form [LoginMenu]?
    there's no code in LoginMenu, just buttons that i right-click > Build Event > marcro
  6. #4
  7. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2012
    Posts
    18
    Rep Power
    0
    ah crap, sorry didn't read carefully and i can't edit post...




    Private Sub cmdLogin_Click()
    'Check to see if data is entered into the password box
    If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
    MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
    Me.txtPassword.SetFocus
    Exit Sub
    End If

    'Check value of password to see if this
    'matches value chosen in combo box


    If Me.txtPassword.Value = DLookup("password", "tblUsers", _
    "[ID]=" & Me.cboUsername.Value) Then
    ID = cboUsername

    'Close logon form and open loginmenu form


    strLoginName = Me.cboUsername
    DoCmd.Close acForm, "Login"
    DoCmd.OpenForm "LoginMenu"

    Else
    MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
    "Invalid Entry!"
    Me.txtPassword.SetFocus
    End If

    End Sub
  8. #5
  9. No Profile Picture
    Contributing User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2004
    Posts
    72
    Rep Power
    11
    Are you absolutely sure that the form with your log in button is called "Login"? Try replacing this line:

    Code:
    DoCmd.Close acForm, "Login"
    with this:

    Code:
    DoCmd.Close acForm, Screen.ActiveForm.Name
    Edit: Alternatively, just right-click the form in the navigation pane, select 'Rename', and call it Login!
  10. #6
  11. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2012
    Posts
    18
    Rep Power
    0
    Originally Posted by Charlie_B
    Are you absolutely sure that the form with your log in button is called "Login"? Try replacing this line:

    Code:
    DoCmd.Close acForm, "Login"
    with this:

    Code:
    DoCmd.Close acForm, Screen.ActiveForm.Name
    Edit: Alternatively, just right-click the form in the navigation pane, select 'Rename', and call it Login!
    DoCmd.Close acForm, "Login" << yeah it's called Login
    isn't this a do command to close the current form "login" ??
    what's wrong with that??
  12. #7
  13. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Jun 2011
    Location
    South Jersey
    Posts
    544
    Rep Power
    59
    Long story short. You've trying to reference a field from a form that's already been closed.
    in your code for the login form you have the line.
    Code:
    docmd.close acform, "Login"
    This closes the login form. Then you open the form "loginmenu" and run the code:
    Code:
     if [Forms]![Login]![cboUsername]="Admin" Then
    this code specifically references a form that you've already closed. You'll have to save the required field to either: 1. call your if statement before you close the login form. 2. save your user name to the newly opened form. or 3. save your username to a global variable.

Similar Threads

  1. Run Excel Macro from MS Access
    By tuktuk in forum Microsoft Access Help
    Replies: 2
    Last Post: September 12th, 2006, 11:58 AM
  2. Using Access Macro with ASP
    By Tulkas in forum ASP Development
    Replies: 4
    Last Post: April 4th, 2006, 02:23 PM
  3. MS Access Macro Problem
    By KnightAL in forum Microsoft Access Help
    Replies: 7
    Last Post: January 7th, 2006, 07:57 PM
  4. Access 2002:Macro from a Data Access Pages
    By rbunton in forum Microsoft Access Help
    Replies: 0
    Last Post: November 12th, 2004, 03:28 PM
  5. Access macro from asp
    By Steve Schofield in forum ASP Development
    Replies: 0
    Last Post: July 18th, 2000, 07:16 PM

IMN logo majestic logo threadwatch logo seochat tools logo