input text value into table!!!!!!!!

johnyjassi

Registered User.
Local time
Today, 12:29
Joined
Jun 6, 2008
Messages
64
Hi experts,

I am new in Ms Access, and I am working on the part of this project, where i have to display the username who has logged in(this problem was solve by one of the experts here). Now i want that value to automatically populate into the table column when we click on "Save Record". I have column in my table for username.
Any help will be appreciated.
Thanks in advance.
 
If your form is bound then value in your text box will automatically stored to the field in the table to which the above said field is bound

But if you are using unbound table then you can use sql statement to insert into table like below

DoCmd.RunSQL ("INSERT INTO table1 ( field1) values (forms!frmMyForm!Text1)")

in the above statement table1 is the table in which you want to store the user name
field1 is the field in that table myform is the name of form text1 is the control on the form from which you are taking user name
 
Hi khawar,

Thanks for your help, it works but it is inserting the value into the next row not with the same row in which i am saving the data. any other idea!!

Thanks
 
you have to run an update statement
I will write that for you give me the name of your table and fields you want to update
 
I think it should be
update callinfo set username = forms!frmMyForm!Text1 where <" what option should i give here, so that it should update the current field with rest of the information">
 
Why not just make the default value of a form control bound to that field refer to the form control containing the name?
 
If you table has a single record this will work

Docmd.runsql("UPDATE Table1 SET Table1.UserName = 'User Name you want to insert';"
 
Thanks for the help guys, Paul's idea worked and it is simple.
khawar's idea is good but good for one row update.
Thanks a lot!!!!!!!!!!!!!!!
 

Users who are viewing this thread

Back
Top Bottom