Copy Field to another field in different Table

P

paduanow

The application I am writing will be used to send data via file to a main
database. The application forces the use to input a UserID during the
initial installation. The UserID will never change once entered. The
application that I am writing will have multiple users in different location
in Calif.

The UserID is stored in table User, field UserID.

The main table where the data will be sent is called DateCol. It has a
field called IDUser. I need to set the default value to the value of UserID.
Once this is done it will never change.

Private Sub Client_ID_AfterUpdate() 'UserID field'

DataCol.IDUser.DefaultValue = User.UserID

End Sub

I get Runtime error 424 What am I doing wrong

In my UserID form Afterupdate
 
K

Klatuu

A form knows nothing about tables, you have to use another method.

What is the record source of the form?
A default value can be set at the field level in a table, but it looks like
you need to do it at the form control level.

Error 424 means an object is required. You are getting the error because
DataCol is not established as an object.

If you have a control on the form for UserID, you don't need to use
DefaultValue and you need to do a DLookup to get the value from the DataCol
table.

Me.UserID = DLookup("[IDUser]", "[DataCol]")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top