Results 1 to 7 of 7
  1. #1
    Mar is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2009
    Posts
    4

    Automaticallty insert a value from a Form into a Table

    Hello,

    I´m working for a big company that need to use an efficient tool like Access to create a database. I´m working on it for a month now, totally newbie in Access it takes ages to dare playing with all the functions! (And now there is 1 week left before the presentation..)
    Currently, I´m trying to create an automatic action in a table, I made a login dialog when opening the database that display the name of the persons allowed to open or modify it, then from the Home tab there is the opportunity to edit an action (such as "next meeting will be on 30th, September", etc) linking to a table. I would like the field "created by" in the table automatically recording the name of the current user, is it possible? because I still didn´t find this kind of programming...

    I will be very grateful for any help or tip

  2. #2
    SoftwareMatters is offline Access VBA Developers
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    Have you secured the database using the in-built functions so users have to log in or have you created a log in yourself?

    If it is the in-built functions you can capture the current user using CurrentUser()
    so in the field "Created By" put =CurrentUser() for the deafult value - now ehenever you add a record the CurrentUser will be added.

  3. #3
    Mar is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2009
    Posts
    4
    Thanks for the answer SoftwareMatters. I created a log in myself, following the path of Northwind example. When I use the CurrentUser() function in Default value it´s the user name of the computer that comes out.
    I tried to put =[TempVars]![UsuariosID] which worked for the Home page (a simple combobox) but then a msg box appears saying it cannot find this tempory variable, and then only the users ID number appears, why? Or rather how should I modificate the expression so it works?

  4. #4
    SoftwareMatters is offline Access VBA Developers
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    If you want to store the user to use in different forms in the database I would store it in a database property and call it from a public sub in a module. To do this:

    1. Set up code that stores the user name/ID at the login in to a database property.
    2. Write code in your module (if you have one if not create one) that calls the database property.
    3. Wherever you need the current user call the sub.

  5. #5
    Mar is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2009
    Posts
    4
    Well, I never used Modules before... But I know the theory roughly, How can I set up this code? will it allow each user to have his own session (with the possiblity of sharing or not file with the other users)?
    I think I did a very basic login, maybe too basic??

    It´s a form dialog, with a combo box calling the usernames from a table. on click on Login button, it opens the Home page (through macros) if the combo box isn´t empty, and the user name appears as well in the page.
    To secure the database I opened my database in exclusive and I encrypted it so when opening it from anywhere a password is required.
    Here I am.

  6. #6
    SoftwareMatters is offline Access VBA Developers
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    Yes there will be a problem if you have multiple users with a shared front end.

    Thinking about what you have and what you are trying to achieve I think the following will work but you will need a form that is always open (your main/home form).

    On the home form create a combo box which lists the users. When you open the form and the user selects who they are right this in to the combo box. Now you can read from this combo box using forms!home!comboxname from any other form.

  7. #7
    Mar is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2009
    Posts
    4
    Well, as you said, I can read it from any other form, not table.
    What is strange is that only the primary keys come out in the table, not the names.
    Anyway, thank you for your help.
    If there is other tip I´ll be glad to try them, otherwise I think I´m gonna to delete this field for the moment, and when it will be less urgent I´ll learn how to use modules.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Insert only permission?
    By wordracr in forum Security
    Replies: 1
    Last Post: 01-14-2010, 04:48 PM
  2. Insert an image in database
    By microbert in forum Database Design
    Replies: 1
    Last Post: 06-22-2009, 01:57 PM
  3. Insert Query output into a table
    By ammu_sridhar in forum Programming
    Replies: 1
    Last Post: 06-12-2009, 01:09 AM
  4. Updating two tables using SQL Insert Into
    By glazzaro in forum Programming
    Replies: 0
    Last Post: 05-02-2008, 10:52 PM
  5. Insert Dash between set of Numbers
    By Jhankish in forum Programming
    Replies: 2
    Last Post: 04-19-2007, 08:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums