use a queries sql in a form

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

Guest

Hi
We have a form which updates a table once the submit button is clicked. We
would like to add a queries SQL onto this button so once the records are
updated then the query will also run.

The following is the SQL we have from the query we have built and would like
to use.

INSERT INTO Tbl_BuyersAuthorityKC ( Keycode, Style, Description, Net, GST,
Total, Quantity )
SELECT Tbl_BuyersAuthorityKC_Temp.Keycode, Tbl_BuyersAuthorityKC_Temp.Style,
Tbl_BuyersAuthorityKC_Temp.Description, Tbl_BuyersAuthorityKC_Temp.Net,
Tbl_BuyersAuthorityKC_Temp.GST, Tbl_BuyersAuthorityKC_Temp.Total,
Tbl_BuyersAuthorityKC_Temp.Melb
FROM Tbl_BuyersAuthorityKC_Temp;

We are hoping someone will know how to transfor this SQL code so it will run
once the button is clicked.

Thanks
 
Noemi said:
Hi
We have a form which updates a table once the submit button is clicked. We
would like to add a queries SQL onto this button so once the records are
updated then the query will also run.

The following is the SQL we have from the query we have built and would like
to use.

INSERT INTO Tbl_BuyersAuthorityKC ( Keycode, Style, Description, Net, GST,
Total, Quantity )
SELECT Tbl_BuyersAuthorityKC_Temp.Keycode, Tbl_BuyersAuthorityKC_Temp.Style,
Tbl_BuyersAuthorityKC_Temp.Description, Tbl_BuyersAuthorityKC_Temp.Net,
Tbl_BuyersAuthorityKC_Temp.GST, Tbl_BuyersAuthorityKC_Temp.Total,
Tbl_BuyersAuthorityKC_Temp.Melb
FROM Tbl_BuyersAuthorityKC_Temp;

We are hoping someone will know how to transfor this SQL code so it will run
once the button is clicked.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Use the DoCmd.OpenQuery method or the QueryDef.Execute method.

DoCmd.OpenQuery "query name"

==

dim db as dao.database
dim qd as dao.querydef
set db = currentdb
set qd = db.querydefs("query name")
qd.execute dbFailOnError

==

The last is preferred, cuz it has error handling "dbFailOnError."

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQjC5z4echKqOuFEgEQICrQCgrCSxzmew2blEymVAl8SXyKno7KcAn3tU
IoKLIrk4Net+3wRrfT0AUyV5
=Jccx
-----END PGP SIGNATURE-----
 
Check Access VB Help on the Execute Method (either DAO or ADO).

You can also use RunSQL Method of the DoCmd Object.

Execute is the prefered method.
 
Back
Top