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

    Missing one line of code

    If Y = 2 Then
    DoCmd.OpenForm "frm a"

    Missing line of Code :What I want code to do here is (If button c is clicked on frm a then following should happen)


    DoCmd.OpenForm "frm b"
    Forms!frm b!txtUserID = X


    Forms!frm b!txtUsername = txtUsername
    Forms!frm b!combo1.Visible = False


    As both forms gets open simultaneously and menu menu which is form a goes at the back of form b

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Those are the actual form names? Advise not to use spaces in naming convention. They will cause you a lot of frustruation.

    I don't understand the issue. What exactly do you want?
    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.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    It looks to me you need the code behind BUTTON C_ ON CLICK on "frm A" to be

    DoCmd.OpenForm "frm b"
    Forms!frm b!txtUserID = X
    Forms!frm b!txtUsername = txtUsername
    Forms!frm b!combo1.Visible = False

  4. #4
    jj1 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    128
    I want to basically open the main menu and from main menu click button which opens a formB on which i want to make few combo boxes as invisible depending upon the level of permission the person has. So I have put above code in the Login form on Ok button but what's happening is its opening both the forms (main menu and formB together) and putting the formB on top instead of main menu. I hope i am able to explain you

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Where is the code that is opening formB at same time as main menu? If you don't want that to happen, then eliminate that code.
    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.

  6. #6
    jj1 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    128
    Here is my entire code
    Dim X As Long
    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 & "'"))

    'We have a valid user
    If Y = 1 Then
    DoCmd.OpenForm "frmmainmenu"
    Forms!frmB!txtUserID = X
    Forms!frmB!txtUsername = txtUsername
    DoCmd.Close acForm, "LoginF"
    End If
    If Y = 2 Then
    DoCmd.OpenForm "frmHomePage"
    DoCmd.OpenForm "frmB"
    Forms!frmB!txtUserID = X
    Forms!frmB!txtUsername = txtUsername
    Forms!frmB!combo1.Visible = False
    DoCmd.Close acForm, "LoginF"

    Please help

  7. #7
    jj1 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    128
    Can you also please see my entire code posted I think we are close

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Why don't you remove the line:

    DoCmd.OpenForm "frmB"
    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.

  9. #9
    jj1 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    128
    Because from the frmB Permissions are checked
    Forms!frmB!txtUserID = X
    Forms!frmB!txtUsername = txtUsername

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    If that code is behind the login form then that is why it is opening both forms. If you don't want to open frmB from the login form then don't have code there.

    Otherwise, if you want frmHomePage to have focus then change the order of the code so it is opened last.
    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. VBA code to delete the 2nd line in a csv file
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 03-02-2013, 02:16 AM
  2. trouble with one line of code
    By mejia.j88 in forum Programming
    Replies: 3
    Last Post: 01-25-2012, 10:53 PM
  3. How to execute Line of Code
    By jo15765 in forum Programming
    Replies: 4
    Last Post: 06-22-2011, 05:37 PM
  4. How to do line by line compare of VB code?
    By Buakaw in forum Access
    Replies: 2
    Last Post: 02-14-2011, 11:46 PM
  5. Anything wrong with this one line of code?
    By alsoto in forum Reports
    Replies: 3
    Last Post: 07-01-2009, 09:23 AM

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