By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,659 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,659 IT Pros & Developers. It's quick & easy.

Open form for corresponding combobox selection

P: 9
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
Expand|Select|Wrap|Line Numbers
  1.   'Open "Info_form" and pass the User_Name in OpenArgs parameter
  2.         DoCmd.OpenForm "Info_form", , , , , , Me.User_name
  3.        Forms("Info_Form").Button1.Visible = (Me.User_name = "Admin")
  4.         DoCmd.Close acForm, Me.Name
Apr 5 '12 #1
Share this Question
Share on Google+
5 Replies

P: 31
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!
Apr 5 '12 #2

P: 9
Hi malathi,
yes . what I have rite now is this. How and where to include the code to open the corresponding recordset.
Apr 5 '12 #3

P: 759
Try this:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "Info_form", , , "UserName = " & Me.User_name, , , Me.User_name
If don't work, post the implied tables structures.

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_Form").Button1.Visible = (Me.User_name = "Admin")
DoCmd.Close acForm, Me.Name

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

Cheers !
Apr 5 '12 #4

P: 9
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.SearchForRecord , "", acFirst, "[User ID] = " & "'" & Screen.ActiveControl & "'"
Apr 9 '12 #5

P: 9
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
Apr 9 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.