Solved Fill Access Table by using INSERT INTO ..SELECT.. (1 Viewer)

Gizem

Member
Local time
Today, 13:53
Joined
Nov 29, 2021
Messages
30
Hallo together,

few months ago you helped me a lot. Now i need help again. Now i want to fill my Acces Table with an other Acces Table. I tried it with INSERT INTO.. SELECT.. , but it does not work. Maybe you have a better solution or you can find my failure. I chose this option becauce, i want to transport not all rows and columns.

Table1:
IDPositionP_NAME

Table2:
P_IDP_NAME_L
222P1Volkswagen_Golf
312P1Volkswagen_Polo
999P2Volkswagen_Passat
221P2Volkswagen_Tiguan

My goal is to fill Table1, column P_NAME with Table2 column P_NAME_L. But i have to check in table2 P_ID. If P_ID starts with 9 (the red one) than i have to ignore the hole row and got to the next.

I try to solve this problem since two days. Thank you in advance :)
 

Gizem

Member
Local time
Today, 13:53
Joined
Nov 29, 2021
Messages
30
Code:
Dim SQLInsert As String
SQLInsert = " INSERT INTO Table1  " _
    & "SELECT Me!Table2.P_NAME_L " _
    & " FROM Table2;"
CurrentDb.Execute SQLInsert


I get a run-tim-error 3061.To few parameters. Expected 1..
 

SHANEMAC51

Active member
Local time
Today, 14:53
Joined
Jan 28, 2022
Messages
310
Code:
Dim SQLInsert As String
SQLInsert = " INSERT INTO Table1(P_NAME)  " _
    & "SELECT Table2.P_NAME_L " _
    & " FROM Table2" _
    & " where p_id<>"999P2"
CurrentDb.Execute SQLInsert
 

Gizem

Member
Local time
Today, 13:53
Joined
Nov 29, 2021
Messages
30
Now i have to do the same with a Report. My source is now a Report. Here it does not work. Do you see where the failure is ?
Dim SQLInsert As String
SQLInsert = " INSERT INTO Table3(P_NAME) " _
& "SELECT F_Projekt.P_NAME " _
& " FROM F_Projekt" _
& " WHERE GEWICHT_KG <> '0' "

CurrentDb.Execute SQLInsert

I get an error 3131: Syntax Error in FROM clause
 

Minty

AWF VIP
Local time
Today, 12:53
Joined
Jul 26, 2013
Messages
10,371
Why would you be basing an insert query from a report?
What is F_Projekt - a form?
 

SHANEMAC51

Active member
Local time
Today, 14:53
Joined
Jan 28, 2022
Messages
310
Code:
Dim SQLInsert As String
SQLInsert = " INSERT INTO Table3(P_NAME) " _
& " SELECT F_Projekt.P_NAME"  _
& " FROM F_Projekt"  _
& " WHERE GEWICHT_KG <> '0' "

CurrentDb.Execute SQLInsert
 

bastanu

AWF VIP
Local time
Today, 04:53
Joined
Apr 13, 2010
Messages
1,402
Is GEWICHT_KG text or number, if number you don't need to wrap the 0 in single quotes.
 

Gizem

Member
Local time
Today, 13:53
Joined
Nov 29, 2021
Messages
30
I tried it for my Report but it does not work. I get a syntax error : syntax error in FROM clausel..
 

SHANEMAC51

Active member
Local time
Today, 14:53
Joined
Jan 28, 2022
Messages
310
I tried it for my Report but it does not work. I get a syntax error : syntax error in FROM clausel..
check the names of the table and fields
or lay out an example of the database
 

Gizem

Member
Local time
Today, 13:53
Joined
Nov 29, 2021
Messages
30
check the names of the table and fields
or lay out an example of the database
1643702109756.png

It seems like this. But it isn't the same
 

Attachments

  • 1643702072542.png
    1643702072542.png
    86 KB · Views: 242

June7

AWF VIP
Local time
Today, 03:53
Joined
Mar 9, 2014
Messages
5,488
F_Projekt is a report? Why does it have prefix of F?

Cannot pull data from a report like that. Why do you not pull from table(s) since that's where the data is?
 

SHANEMAC51

Active member
Local time
Today, 14:53
Joined
Jan 28, 2022
Messages
310
this is more like a report from the entire table, and you need to set a selection when opening the report
 

Gizem

Member
Local time
Today, 13:53
Joined
Nov 29, 2021
Messages
30
F_Projekt is a report? Why does it have prefix of F?

Cannot pull data from a report like that. Why do you not pull from table(s) since that's where the data is?
Yes it is a report. I don't know 😅
I have to pull data from this report. My superior ruled it.
 

SHANEMAC51

Active member
Local time
Today, 14:53
Joined
Jan 28, 2022
Messages
310
you need to create a form with search fields by last name, first name, position .....
in it the boss will see what is needed

the report is intended for another
 

SHANEMAC51

Active member
Local time
Today, 14:53
Joined
Jan 28, 2022
Messages
310
lay out a sample of the database to make a form on it (and possibly a report)
 

Users who are viewing this thread

Top Bottom