Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating 2

Status
Not open for further replies.

peljo

Technical User
Mar 3, 2006
91
BG
I want to make an update code without referring to the form

My update query reads in is sql as follows
Dim SQL As String
StrSQL = "UPDATE products SET products.new = [products].[grossprice]-[products].[grossprice]*28/100"
I want to rewrite it in the following way :
Dim Diff As String
Diff = [products].[grossprice] - [products].[grossprice]
SQL = "UPDATE products SET products.new = diff*28/100 "

However this effort fails since i have to refer to a form.Can i build a code without referring to a form?
 
Diff = [products].[grossprice] - [products].[grossprice]
How do you expect that Diff is not 0 ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Not sure why you do not want to use the form since this is where you expressed value comes from. You will need to reference it somewhere.

If the form is always going to be open, then you can create a public function that looks at the form to get it's value and then use the function in the query.

If the form is not always open, then you can set a public variable within the Event Procedure that would have triggered the above code, then use a public function to retrieve the value from the public variable.

Where is the code you have above and how does it get triggered?

Why do you NOT want to reference the form?

ProDev, Builders of Affordable Software Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Thank you for your reply.Actually i wanted to cut short the line for a better view.Something like that :
Dim Bulk As String
Bulk = " UPDATE products SET products.office = [products].[grossprice]-[products].[grossprice]"
Dim StrSQL As String
StrSQL = Bulk * 28 / 100
CurrentDb.Execute StrSQL

End Sub

But it doesnt work. What may be the reason?
 
Where is this code running? Where is this event procedure? Is it in the Products form? If so, what is triggering it? You have the End Sub but not the Sub Name.

Also as mentioned by PHV, you have the same text box referenced twice. Your result is always going to be zero.

ProDev, Builders of Affordable Software Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top