Microsoft Access Logging System 2nd open form with the loging form user name

Question

here i have one problem happened when i do a library booking system in Microsoft Access 2010, this is a sample, please have a look:

frmLogin:

while when the user press this "login" button, and open a new form, let's call it "frmMain", I want in this "frmMain" somewhere shows the username as it is booking system, but i searched the whole internet, i cant find this kind of information. so hope there
is somebody can borrow me a hand, please!!

Answers

The use of a temporary variable will greatly assist you here. Have your login button include the creation of a temporary variable by saying

tempvars.add "strUserName", me.cmbTenantName.value

make sure that you specify that your storing the VALUE or it will try to store the object and give you an error

if cmbTenantName is a number, you might have to use cmbTenantName.Column(x).value Where x is the field number contained in the combo box. Fields are numbered starting at 0, so the first field in the combo box is .column(0) .. the
second is (1), etc.

once you open the frmMain, you can access the temporary variable by

strName = tempvars!strUserName

when you're done with a temporary variable, delete it with

tempvars.remove "strUserName"

temporary variables stay in memory until you remove them or close Access, so you could keep strUserName as a temporary variable and use it on every form if you wanted.

All replies

i have searched the internet and found one that could be a hint for me for this problem, which can be checked here: http://www.youtube.com/watch?v=7Xe-vHMNQfA

well, in this tutorial, in his form 1, the control is a textbox, so in the form 2.

well, for my one, may be a bit special, in form 1, this is a combobox, well in form 2, it is a textbox.

i have tried to add one textbox in form 1 named "txtUser" and use it to get the value from the combobox, check from here: http://en.allexperts.com/q/Using-MS-Access-1440/Fill-text-box-based.htm, but looks like there will no error pop out with asking
me to debug, but it will show a " ?name!#" in my name field in form 2.

now i'm almost getting crazy with this issue, any help will be great appreciated!

The use of a temporary variable will greatly assist you here. Have your login button include the creation of a temporary variable by saying

tempvars.add "strUserName", me.cmbTenantName.value

make sure that you specify that your storing the VALUE or it will try to store the object and give you an error

if cmbTenantName is a number, you might have to use cmbTenantName.Column(x).value Where x is the field number contained in the combo box. Fields are numbered starting at 0, so the first field in the combo box is .column(0) .. the
second is (1), etc.

once you open the frmMain, you can access the temporary variable by

strName = tempvars!strUserName

when you're done with a temporary variable, delete it with

tempvars.remove "strUserName"

temporary variables stay in memory until you remove them or close Access, so you could keep strUserName as a temporary variable and use it on every form if you wanted.