Open form for corresponding combobox selection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashok srmuniv
    New Member
    • Apr 2012
    • 9

    Open form for corresponding combobox selection

    Hi,
    I have database with two forms(Login form & Info form) and a table. When I login with a user name , it has to open the "Info form" with the corresponding username's record. Please help me to fix this. Below this the code what I have now. Thank you
    Code:
      'Open "Info_form" and pass the User_Name in OpenArgs parameter
            DoCmd.OpenForm "Info_form", , , , , , Me.User_name
           Forms("Info_Form").Button1.Visible = (Me.User_name = "Admin")
            DoCmd.Close acForm, Me.Name
    Last edited by NeoPa; Apr 5 '12, 10:07 PM. Reason: Added mandatory [CODE] tags for you.
  • Malathi
    New Member
    • Mar 2012
    • 31

    #2
    You are opening the form and passing the username. But you are not opening the recordset of the paricular user in the form and also not passing the values. I think this might be the point!

    Comment

    • ashok srmuniv
      New Member
      • Apr 2012
      • 9

      #3
      Hi malathi,
      yes . what I have rite now is this. How and where to include the code to open the corresponding recordset.

      Comment

      • Mihail
        Contributor
        • Apr 2011
        • 759

        #4
        Try this:
        Code:
        DoCmd.OpenForm "Info_form", , , "UserName = " & Me.User_name, , , Me.User_name
        If don't work, post the implied tables structures.

        PS:
        Edit your preview post (click Edit button)
        Select this text:
        'Open "Info_form" and pass the User_Name in OpenArgs parameter
        DoCmd.OpenForm "Info_form" , , , , , , Me.User_name
        Forms("Info_For m").Button1.Vis ible = (Me.User_name = "Admin")
        DoCmd.Close acForm, Me.Name

        Click the <CODE/> button, in order to appear like this:
        Code:
        'Open "Info_form" and pass the User_Name in OpenArgs parameter
        DoCmd.OpenForm "Info_form", , , , , , Me.User_name
        Forms("Info_Form").Button1.Visible = (Me.User_name = "Admin")
        DoCmd.Close acForm, Me.Name
        Do that from now when you post code !

        Cheers !

        Comment

        • ashok srmuniv
          New Member
          • Apr 2012
          • 9

          #5
          Hi Mihail,
          This is not workin. let me show you some other code.I have a drop down in the Infoform for admin,where he can view all the users through a drop down.I want something similar like this when a user login it should show their form.

          User_ID = Me.NName.Value
          DoCmd.SearchFor Record , "", acFirst, "[User ID] = " & "'" & Screen.ActiveCo ntrol & "'"

          Comment

          • ashok srmuniv
            New Member
            • Apr 2012
            • 9

            #6
            so the username comes from "User ID" and when the form opened by a user , it shold show up only his own record.
            Please help me on this

            Comment

            Working...