How to reference to a table?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi.

I have one form that is linked to one of 3 tables. All data is successfully
entered to that table when I press Add button on my form. Now I want one
field to be inserted to another table as well. Here is the line of code, but
it's incorrect.

Tables!Employment_Data!Employment_Name = Line_1 & " " & Line_2 & " " & Line_3

Can you help me with it? How to make a field to be entered into more than
one tables?

Thanks!
 
Hi.

I have one form that is linked to one of 3 tables. All data is successfully
entered to that table when I press Add button on my form. Now I want one
field to be inserted to another table as well. Here is the line of code, but
it's incorrect.

Tables!Employment_Data!Employment_Name = Line_1 & " " & Line_2 & " " & Line_3

Can you help me with it? How to make a field to be entered into more than
one tables?

You could include the second table in your form's Recordsource, then you'd reference it like this:

Me.Employment_Name = Line_1 & " " & Line_2 & " " & Line_3

However, this often doesn't work out, since you may not be able to include that table in your recordsource. If that's
the case, then you'd need to use an Insert statement:

Currentdb.Execute "INSERT INTO Employment_Name(Employment_Name) VALUES('" & Line_1 & " " & Line_2 & " " & Line_3 &")"

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
Hi, Scott.

Thank you very much for response! The second solution works fine. But now I
have to find out how to point current database to the Database object. When I
specify the path to it, it works fine, but users will not open the code each
time when the location of the file changes and will not update its path. How
can I specify it?

Dim db = Database
db = ???

It seems to be easy, but I'm new to VBA. Sorry.
 
Never mind, Scott. I fixed it. Thank you!

Scott McDaniel said:
You could include the second table in your form's Recordsource, then you'd reference it like this:

Me.Employment_Name = Line_1 & " " & Line_2 & " " & Line_3

However, this often doesn't work out, since you may not be able to include that table in your recordsource. If that's
the case, then you'd need to use an Insert statement:

Currentdb.Execute "INSERT INTO Employment_Name(Employment_Name) VALUES('" & Line_1 & " " & Line_2 & " " & Line_3 &")"


Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
Back
Top