473,378 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Adding an Unbound Text Box value to Table

I have a custom function I got from the net to get the user. This displays the computer user un an unbound text box on a form. How do I add this to a table?
I cannot pick this as a default value in the table (only custom functions here) - please point me in the right direction - I did search the web but found insufficient help - Mark
Oct 27 '07 #1
6 17084
ADezii
8,834 Expert 8TB
I have a custom function I got from the net to get the user. This displays the computer user un an unbound text box on a form. How do I add this to a table?
I cannot pick this as a default value in the table (only custom functions here) - please point me in the right direction - I did search the web but found insufficient help - Mark
  1. Create a Field in the Table that is the Record Source for your Form, call it Current_User, or any name for that matter.
  2. Bind that Unbound Text Box on your Form to this Field by setting its Control Source Property to Current_User, or any name you previously designated.
  3. Set the Default Value Property of this Field to the Function as in:
    Expand|Select|Wrap|Line Numbers
    1. =fGetUserName()
  4. For every New Record you add through this Form, the return value from the Function will be placed in this Text Box and saved to the underlying Table.
  5. If this Function is only to be used in this 1 Form, it can be declared as Private in the Form's Code Module.
  6. If you want it to be used by more than 1 Form, it should be declared as Public in a Standard Code Module.
  7. Feel free to ask if you need further assistance.
Oct 27 '07 #2
nico5038
3,080 Expert 2GB
An alternative is the Environ() function, you can use as default value for the field:
Expand|Select|Wrap|Line Numbers
  1. =Environ("UserName")
  2.  
Instead of "UserName" you can use also "ComputerName" and every other environmental variable set on the computer.

Nic;o)
Oct 27 '07 #3
Thank you very much for replying to my post - unfortunatly neither suggestion worked (maybe it's my understanding of how this works). I would like this to work like the field in the same table that has a default value of =now() to get when the user made the entry. I am useing Access 2003 - I did not see any functions to get the =Environ() (but I did try this as a default value in my table, and Access said "Unknown Function"). any ideas here would be great! I know Microsoft has a KB article on Audit Trails, let me read that again for clues. Thank you!
Oct 28 '07 #4
nico5038
3,080 Expert 2GB
The =Environ("UserName") as default value will only work "behind" a form.
Just create a form and open the properties of the field. Place the statement in the "Default value" property and add a new record.

Nic;o)
Oct 28 '07 #5
when I edit the text box on my form the properties show the control source to be =CurrentUser() (this shows as ADMIN in the text box - my function (from the net) shows it as mfquigle). If I set the Control Source of the text box to the table ([tblProgram]![EnteredBy]) it does save any value I enter in the text box to the table, but it does not seem to save the default value (which is what I want) to the table (my function returns "#Error" when put as the default value, if I put =Environ("UserName") as the default value the text box returns "#Name?". I did see the Environ function in (under) the form as you said Nico - thank you -
Oct 28 '07 #6
gurmet
6
Hi
Thank you very much it helps me. I m able to save who creates the record by saving the network username and also date/time as when it is created.
The above info helps me as already got the username and date just did not how to save them into the table, and above steps helps me.

Thank you very much.
Regards
Gurmet
Aug 26 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: deko | last post by:
I need to create different recordsets based on queries that use data from unbound fields in a form. I've discovered that I can't do this, and instead need to save the data in question (usually a...
2
by: Todd | last post by:
Hello, I'm curious if anyone knows of a way (if one exists) to tell a form (in Access 2002 VBA) to sort on an unbound column of a combo box on the form. Here's what I want to do: A combo box...
2
by: hmiller | last post by:
Hope I make my case clear!!! I have a table with two bound date/time fields. I want to be able to use an IF statement and DateDiff to return a text message in an unbound text box. I want to do...
20
by: Robert | last post by:
Need some help to stop me going around in circles on this one.... Have a nested subform (subform2) which simulates a continuous form for the record on the parent subform. Subform2 has rows of...
18
by: TORQUE | last post by:
Hi, Im wondering if anyone can help me with a problem. I have a form with more than 50 unbound fields. Some of the fields will be blank from time to time. This seems to be where im having...
4
by: Susan Bricker | last post by:
I have a form that displays record information in Continuous Record display (scrollable list). One of the fields in the record is an Integer value called "rcode" (reason code). But, I don't want...
4
by: zoeb | last post by:
Hi. I have a form which the user enters 2 years worth of data into (one record per year). The aim, is to populate the table this form is based on with 3 more years worth of data (i.e. creating 3...
11
by: jwessner | last post by:
I have a form (Form1) which contains basic Project data and a subform listing the personnel assigned to the Project as a continuous form. Selecting a person on that project and clicking on a command...
4
by: bkberg05 | last post by:
Hi I have a form called Customer whose record source is a table called Customer. The primary key is Customer_ID. On that form, there's a subform called sub_Customer_Contact_Log. It's record...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.