Forms & Update Query

  • Thread starter Thread starter Access Novice
  • Start date Start date
A

Access Novice

I wish to run an update query, which will be based on a certain text field
in a form.

For example: I have a form (based on a table) which contains details
regarding products (name, price, categories etc.) and another form (based on
another table) which contains general parameters, about a certain store.
Let's assume one of the parameters is called "% profit"

I wish to create "After_Update" event for the "% profit" field which will do
as follows: after writing in this field the value 10%, all prices in the
"products details" table will be increased by 10%.

How can this be done?

Thanks,
Tim.
 
Something like this (aircode):

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("YourQuery")
qdf.Parameters(0) = Forms!MyForm![% profit]
qdf.Execute dbFailOnError
qdf.Close

"YourQuery" will be the query that adds 10% to each product. The
Parameters(0) statement tells the SQL the the [% profit] control on the form
is supplying the value.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
What does the term "qdf" means or refers to?


Arvin Meyer said:
Something like this (aircode):

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("YourQuery")
qdf.Parameters(0) = Forms!MyForm![% profit]
qdf.Execute dbFailOnError
qdf.Close

"YourQuery" will be the query that adds 10% to each product. The
Parameters(0) statement tells the SQL the the [% profit] control on the
form
is supplying the value.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

Access Novice said:
I wish to run an update query, which will be based on a certain text
field
in a form.

For example: I have a form (based on a table) which contains details
regarding products (name, price, categories etc.) and another form (based on
another table) which contains general parameters, about a certain store.
Let's assume one of the parameters is called "% profit"

I wish to create "After_Update" event for the "% profit" field which will do
as follows: after writing in this field the value 10%, all prices in the
"products details" table will be increased by 10%.

How can this be done?

Thanks,
Tim.
 
qdf is a variable Arvin's introduced to refer to the QueryDef object. He's
assuming that you've created an Update query (which he's calling "YourQuery"
in his example: replace that with the name of your actual query). Further,
he's assuming that your query has a parameter that he's pointing to the text
box on your form.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Access Novice said:
What does the term "qdf" means or refers to?


Arvin Meyer said:
Something like this (aircode):

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("YourQuery")
qdf.Parameters(0) = Forms!MyForm![% profit]
qdf.Execute dbFailOnError
qdf.Close

"YourQuery" will be the query that adds 10% to each product. The
Parameters(0) statement tells the SQL the the [% profit] control on the
form
is supplying the value.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

Access Novice said:
I wish to run an update query, which will be based on a certain text
field
in a form.

For example: I have a form (based on a table) which contains details
regarding products (name, price, categories etc.) and another form
(based on
another table) which contains general parameters, about a certain store.
Let's assume one of the parameters is called "% profit"

I wish to create "After_Update" event for the "% profit" field which
will do
as follows: after writing in this field the value 10%, all prices in the
"products details" table will be increased by 10%.

How can this be done?

Thanks,
Tim.
 
Back
Top