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

    Question

  • hi, everyone,

    long time havent been here, miss you all,

    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: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!!

    Thanks in advance!


    Tuesday, December 11, 2012 6:57 AM

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.  

    • Marked as answer by EmilyTingChina Thursday, December 13, 2012 6:49 AM
    Wednesday, December 12, 2012 7:21 PM

All replies

  • hi, all viewers, 

    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!

    Wednesday, December 12, 2012 9:00 AM
  • 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.  

    • Marked as answer by EmilyTingChina Thursday, December 13, 2012 6:49 AM
    Wednesday, December 12, 2012 7:21 PM
  • hi, Tom,

    greatly thanks for your reply, i just tried it and it totally works for me, so appreciate your assist!

    Thanks a lot!

    Thursday, December 13, 2012 6:51 AM