"insert into" query

G

Guldo K

Hello.
I can't understand how does this kind of query work.
I set it up to look at some strings on a form,
look into a Table for records determined by such strings,
then insert values from both the form and the Table.

So, there are values from two textboxes inserted into
two fields of Table2, then two fields from Table1
inserted into Table2. For the last of them, there's
a "having" statement, depending on another textbox
in the same form. I mean the "having" cell value is
[Forms]![myform]![field1]

This works as a "select" query, but as I turn it into
a "insert into" query, 0 records are processed.

Could you let me understand why?

Thanks a lot,

*Guldo*
 
J

John Vinson

Hello.
I can't understand how does this kind of query work.
I set it up to look at some strings on a form,
look into a Table for records determined by such strings,
then insert values from both the form and the Table.

So, there are values from two textboxes inserted into
two fields of Table2, then two fields from Table1
inserted into Table2. For the last of them, there's
a "having" statement, depending on another textbox
in the same form. I mean the "having" cell value is
[Forms]![myform]![field1]

This works as a "select" query, but as I turn it into
a "insert into" query, 0 records are processed.

Could you let me understand why?

Thanks a lot,

*Guldo*

Care to post the SQL of the query? It's more than a bit difficult for
us to tell what is wrong with the query if we can't see the query!
 
G

Guldo K

John Vinson said:
Care to post the SQL of the query? It's more than a bit difficult for
us to tell what is wrong with the query if we can't see the query!

Sorry...

INSERT INTO Gestione3 ( prezzo, peso, descrizione, bilancia )
SELECT [Forms]![Accoda]![importo] AS Prezzo, [Forms]![Accoda]![peso] AS Peso, Gestione1.descrizione, Gestione1.bilancia
FROM Gestione1, Gestione3
GROUP BY [Forms]![Accoda]![importo], [Forms]![Accoda]![peso], Gestione1.descrizione, Gestione1.bilancia
HAVING (((Gestione1.bilancia)=[Forms]![Accoda]![bilancia]));

Thanks,

*Guldo*
Access 2k
 
J

John Vinson

INSERT INTO Gestione3 ( prezzo, peso, descrizione, bilancia )
SELECT [Forms]![Accoda]![importo] AS Prezzo, [Forms]![Accoda]![peso] AS Peso, Gestione1.descrizione, Gestione1.bilancia
FROM Gestione1, Gestione3
GROUP BY [Forms]![Accoda]![importo], [Forms]![Accoda]![peso], Gestione1.descrizione, Gestione1.bilancia
HAVING (((Gestione1.bilancia)=[Forms]![Accoda]![bilancia]));

I think the trouble is that you're trying to Group By fields - the
Form references - which aren't in the table. Change the Group By
aggregate function under the two form references to Expression - or,
since you're not obviously doing any totalling, simply turn off the
summation button.
 
G

Guldo K

John Vinson said:
I think the trouble is that you're trying to Group By fields - the
Form references - which aren't in the table. Change the Group By
aggregate function under the two form references to Expression - or,
since you're not obviously doing any totalling, simply turn off the
summation button.

That worked great. Thanks for your help. ^_^

*Guldo*
 

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