Notices

Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

Thread: ms Access Macro Help

Results 1 to 7 of 7
Share This Thread →
  1. #1
    jeffrey159 is offline Registered User
    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
    meratigoerr's Avatar
    meratigoerr is offline Contributing User
    Join Date
    Jun 2011
    Location
    South Jersey
    Posts
    544
    Rep Power
    58
    Can you post the code you are using to open the form [LoginMenu]?

  3. #3
    jeffrey159 is offline Registered User
    Join Date
    Jul 2012
    Posts
    18
    Rep Power
    0
    Quote Originally Posted by meratigoerr View Post
    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

  4. #4
    jeffrey159 is offline Registered User
    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

  5. #5
    Charlie_B is offline Contributing User
    Join Date
    Jul 2004
    Posts
    72
    Rep Power
    10
    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!

  6. #6
    jeffrey159 is offline Registered User
    Join Date
    Jul 2012
    Posts
    18
    Rep Power
    0
    Quote Originally Posted by Charlie_B View Post
    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??

  7. #7
    meratigoerr's Avatar
    meratigoerr is offline Contributing User
    Join Date
    Jun 2011
    Location
    South Jersey
    Posts
    544
    Rep Power
    58
    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.

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

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

ASP Free Advertisers and Affiliates