Results 1 to 4 of 4
  1. #1
    joeydeck is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    26

    How to populate a field with a variable or another way around my problem

    Hello all,


    I am creating a database project and i have run into a problem at which my knowledge is limited. I have created log in form which uses a 'User Table' to authenticate a password. This then Brings a Navigation form.
    I then want each user to be able to add their own product into 'Product_Frm' which will go into into a 'Products_Tbl'. This will then filter down to each Members Id. The problem I am having is their will be 2 key fields 'Product Id' and 'Member Id'. How can i get this to work?

    I have created a global variable which stores the username when they log in called 'strUsername', can this be automatically added in to the 'Member' field on the 'Products_frm' and i was thinking of filtering this to show only the User who is logged in Products.

    If there is a better way to go around this i would be very grateful,

    Thanks
    Joe

  2. #2
    R_Badger is offline Knows a few tricks
    Windows XP Access 2003
    Join Date
    Feb 2012
    Location
    Suffolk, UK
    Posts
    262
    The easiest way is to create a new module and in it put simply:

    Code:
    Public Function Username()
    Username=strUsername
    End Function
    then in your default value for your favored field "= username()" that should then place the desired string in the field as default for new records.

    Although your approach could be used, i would strongly recommend normalizing as opposed to using strings in such a case.

  3. #3
    joeydeck is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    26
    Thanks R_Badger, this seems like a good way around it but when i try to add it as the default value it states 'Unknown Function 'Username' in validation expression,??

    Joe

  4. #4
    joeydeck is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    26
    Scratch that, its all sorted now,

    Thanks for your help!

    Joe

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

Similar Threads

  1. Replies: 7
    Last Post: 08-08-2012, 03:28 PM
  2. Variable substitution problem.
    By bsc in forum Programming
    Replies: 2
    Last Post: 01-11-2012, 09:33 AM
  3. Replies: 3
    Last Post: 10-03-2011, 02:33 PM
  4. Problem with filtering on DATE Variable
    By SIGMA248 in forum Programming
    Replies: 1
    Last Post: 04-01-2011, 10:33 AM
  5. Replies: 4
    Last Post: 08-05-2010, 01:26 PM

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