Transfer data from one form to another in vba

AnitaRajam

Registered User.
Local time
Today, 12:56
Joined
Aug 28, 2014
Messages
10
I am new to macros. I would like to display a text entered in form1 (text box) to another combo box which is appearing in form2. Please help
 
Welcome to the Forum! :)

You wouldn't transfer the Form but to the Forms Record Source. So, do the Text Box and the Combo Box share the same Control Source?
 
If the user name matches, i want to filter records based on the user name and display them.

So I want to pass the username to another form.

Thanks...:)
 
I think you should explain further on what you are trying to do because opening a Form based on a previous Form is something different than what you initially postef. So, before posting suggesting anything please explain in depth what you are trying to do.
 
Ok Sure. I am creating login details for my database. I want to display the records entered by the user only. My login form is under the name "Form_Login form" and the main form name is Form_Calender. So I dont know how to get the username from login form to the calender form.

cboStaffName = [Forms]![Login Form]![txtlogin] is not working. It returns Null?

Thanks.
 
Confused you say the name of your Form is Form_Login form but your line shows Login Form, which is it?

Are you closing your Login Form? Because you would need to make in Visible = No which leaves it open but invisible.
 
My form name=Login Form&Calender; Coding is in Form_Login form&Form_Calender.

I want to display the records entered by the user only. So I don't know how to get the username from login form to the calender form.

cboStaffName is the variable name in calender, where I want to retrieve the username.
txtlogin is the textbox to enter username.

cboStaffName = [Forms]![Login Form]![txtlogin] is not working. It returns Null?
Also there is an error msg: "The expression you entered refers to an object that is closed...

Thanks.
 
Right because you are closing the Login Form you need to make it invisible.
 
Do you have a Close button on your Login Form? Please post the code from that Command Button here.
 
But I am writing all the codings under OK button. But it is closing automatically when I click and opening the Calender form.


Private Sub CmdClose_Click()
Application.Quit acExit
End Sub
 
No coding in my exit button.

Private Sub CmdClose_Exit(Cancel As Integer)

End Sub
 
Okay, let's do this... Once the User logs in how do they close the Login Form?
 
Coding in OK button:
If UserLevel = 1 Then
DoCmd.OpenForm "Calender"
Forms![Calender]![txtuser] = Me.txtlogin
Forms![Calender]![txtpwd] = Me.txtpassword

So, Once the calender form opens, the remaining code are not executing? and will the login form automatically closed?
 
Thank you so much. I found the solution. Before I start checking the userlevel, I am closing the form using the code DoCmd.Close and I deleted that and its working fine.

Thanks!!! :)
 
Well, I guess you just needed me to help you think! Glad to assist.
 

Users who are viewing this thread

Back
Top Bottom