Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Value of Field to Duplicate

Status
Not open for further replies.

DarkOne72

Technical User
Jun 14, 2002
210
US
Hello all!

I need help on a form I have that is generated by a query.
what I need to happen is on the form is a Last_User field and I want this duplicated to another table on the event of changing of information on the record. The two tables are Main and tblUserChange. Is there a way to do this?

I tried this:

CurrentDb.Execute "INSERT INTO tblUserChange ([Last_User]) VALUES (" & [Last_User] & ")"

but I can't seem to get that to work.
I also tried the ME! command but I am not 100% sure on how to use that feature to do what I want to do.

Any ideas?

Thanks.
 
You don't say what's not working (error, no error but not inserting etc.) but from the code you've posted I'd imagine you'd need:
Code:
CurrentDb.Execute "INSERT INTO tblUserChange ([Last_User]) VALUES ([red]'[/red]" & [Last_User] & "[red]'[/red])"
Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.

 
Thank you for the fast reply, however when I use your code I don't get an error anymore but it doesn't put the value thats in the cell on the form into the other table, just leaves it blank.

Before I was getting Expected value of atleast 1.
Thanks
 
When you debug the code, step through and see what the value of the [Last_User] value is you're trying to update the table with.

Also, what type of field is [Last_User] and where on the form is it located (main form, subform etc.).

Cheers

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.

 
It is on a main form and it is text in both tables limit of 25 chars (it will show like an a user name of JJones123).

I did Edit watch and then stepinto and it gave this:

"value out of context" and Type says Empty
 
Where are you trying to execute the code to add the row?

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.

 
I have tried it many places, I put it in the AfterUpdate area once I make it an event procedure of the main form, I have also tried it on the fields individually like if they were changed.
 
If you change it to:
Code:
CurrentDb.Execute "INSERT INTO tblUserChange ([Last_User]) VALUES ('" & Me![Last_User] & "')"
That works fine for me in the form's AfterUpdate event.

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.

 
I tried it and it doesn't update the table.
Let me ask if this might have an impact, in the field that I want to duplicate I have the default value to call a procedure to get the windows login, is that a problem?
 
Harley,

i got it to work finally..It was a darn relationship that was stopping it. I appreciate all your help!

Thank You.
 
Glad I could help [smile]

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top