Results 1 to 2 of 2
  1. #1
    oakhoplite is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2018
    Posts
    9

    Question Button that opens a form while closing the current window-macros

    Hello, I have created a login form so that users have to log in before accessing anything. I tried to make the 'submit' button for the login form verify if all information that has been entered is correct before loading the Menu form. All of this works, however, I do not know how to make the Login form close once the Menu form has been loaded. I have tried the following in a macro:



    If DCount("ID";"tblUsers";"[Forms]![Login]![txtUsername]=Username and [Forms]![Login]![txtPassword]=Password")<>0 Then

    Open Form
    Form name: Menu



    Close Window
    Object type: Form
    Object Name: Login
    Save: Prompt

    (I am sorry if the explanation is not clear)

    However, if I click the 'submit' button then I just get an error message (the Menu is not opened and neither is the Login form closed). I would really apreaciate if someone could identify what it is that I am doing wrong (I do not know how to use VBA so if you can please suggest an alternative that does not involve VBA-sorry).
    Thank you!
    Attached Thumbnails Attached Thumbnails this.JPG  

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,742
    I think I eyeballed this OK...
    If Dcount("ID","tblUsers","Username='" & txtUsername & "' AND Password ='" & txtPassword & "'") > 0 Then

    This assumes that the code is contained in the login form's code module. If not add back in the [Forms]! notations with the txtxxxxx fields.
    The first and 3rd arguments in the dlookup must be field names in the domain named in the second argument.


    And I think you want Close Form not Close Window, but not sure, as I don't use macros.
    Last edited by davegri; 07-04-2018 at 10:56 PM. Reason: second thoughts

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

Similar Threads

  1. Replies: 16
    Last Post: 02-01-2018, 07:55 PM
  2. Hyperlink opens duplicate window
    By gunitinug in forum Access
    Replies: 1
    Last Post: 09-04-2017, 05:39 PM
  3. Updating form after updating and closing a popup window
    By Historypaul in forum Programming
    Replies: 2
    Last Post: 04-21-2014, 02:13 AM
  4. Replies: 9
    Last Post: 04-11-2011, 10:55 PM
  5. Computer1 Form Current Record opens on Computer2
    By joefonseca79 in forum Forms
    Replies: 2
    Last Post: 02-20-2011, 04:11 AM

Tags for this Thread

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