INSERT with Random SELECT

0

I have a table with a lot of information and an empty one.

I need to make an INSERT on this empty table with just one information from the other table, but SELECT must be random.

I'm using the following line in VBA:

db.Execute "INSERT INTO tbl_Sorteio SELECT TOP 1 RE, Name_Employee, Case_Number, [Date], [Time], Supervisor, Comment, Client ORDER BY Rnd(Case_Number)"

But I got the following error message:

Remembering, I'm using Access 2013.

    
asked by anonymous 30.09.2018 / 08:15

1 answer

2

I added the FROM clause that was missing and I started filtering the Case_Number instead of sorting the result by it; see if the command below resolves:

db.Execute "INSERT INTO tbl_Sorteio SELECT TOP 1 RE, Name_Employee, Case_Number, [Date], [Time], Supervisor, Comment, Client FROM tbl_Sorteio WHERE Case_Number = Rnd(Case_Number)"
    
01.10.2018 / 13:41