473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Run update query if a check box is ticked

20
Hi
Probably an old question....
I'm trying to run an update query which needs to update files in a table if a check box is ticked.
Please advise.
Thanks!
MikeSA
Oct 3 '07 #1
6 5371
Please provide more information about what you are trying to do. Are you trying to update data on a form? Update fields in records in a table? What are you updating and what do you want the end result to be?
Oct 3 '07 #2
MikeSA
20
Please provide more information about what you are trying to do. Are you trying to update data on a form? Update fields in records in a table? What are you updating and what do you want the end result to be?
Hi Luke
I have an Orders Table with a field called VAT% that must be updated to a value held in a table called Constants, with one record only, containing a field called VATRate. In the Orders table I have a check box field (Yes/No) called VATable that is used as the criteria for the query to decide which records in Orders Table needs to be updated. This works successfully, update query works fine.

But on the Orders Form derived from the Orders Query (select query), I need the query to execute automatically after the Check Box changes state, automatically updating the Orders Table.

Idea is to be able to change the VATRate in one place selectively according to status of Check Box, updating all the relevant records in the Orders Table.

Hope I am making myself understood. Perhaps their is a better way of doing this that I am missing. (So far I have not needed to go the VBA route).

Please advise
Thanks!
MikeSA
Oct 3 '07 #3
Hi Luke
I have an Orders Table with a field called VAT% that must be updated to a value held in a table called Constants, with one record only, containing a field called VATRate. In the Orders table I have a check box field (Yes/No) called VATable that is used as the criteria for the query to decide which records in Orders Table needs to be updated. This works successfully, update query works fine.

But on the Orders Form derived from the Orders Query (select query), I need the query to execute automatically after the Check Box changes state, automatically updating the Orders Table.

Idea is to be able to change the VATRate in one place selectively according to status of Check Box, updating all the relevant records in the Orders Table.

Hope I am making myself understood. Perhaps their is a better way of doing this that I am missing. (So far I have not needed to go the VBA route).

Please advise
Thanks!
MikeSA
Here is my understand:

You have two tables: Orders, Constants
Order Table has fields: VAT%, VATable (y/n), etc.
Constants has a field: VATRate

You have a Form: frmOrders
Forms is based off of the Orders Query

I don't understand:
What the Orders Query is based off. Is it a combination of the Orders and Constants Tables?

What does your update query do? Does it change the VATable to yes or no?

You want to change the VATRate in the Constants table to a different value based on the checkbox in your form? After which you your update query to do whatever it does?

I believe that I can instruct you on how to accomplish these tasks, but I still don't quite understand exactly what you are trying to accomplish.

if you want, feel free to send me a test file of your database at lbaileywork@hotmail.com (please don't distribute)
Oct 3 '07 #4
MikeSA
20
Here is my understand:

You have two tables: Orders, Constants
Order Table has fields: VAT%, VATable (y/n), etc.
Constants has a field: VATRate

You have a Form: frmOrders
Forms is based off of the Orders Query

I don't understand:
What the Orders Query is based off. Is it a combination of the Orders and Constants Tables?

What does your update query do? Does it change the VATable to yes or no?

You want to change the VATRate in the Constants table to a different value based on the checkbox in your form? After which you your update query to do whatever it does?

I believe that I can instruct you on how to accomplish these tasks, but I still don't quite understand exactly what you are trying to accomplish.

if you want, feel free to send me a test file of your database at lbaileywork@hotmail.com (please don't distribute)
Hi Luke
Thanks for the help, I will try to explain:

The Update Query updates the Orders Table VAT% Field from the Constants Table VATRate field if the check box VATable is ticked by the user.

The Constants Table contains the field VATRate, so that the VAT Rate can be changed in the table by the user, only having to change it in one place, using the update query to populate the changes throughout the rest of the Orders Table, those records where the the check box has been ticked by the user.

The Orders Query (select query) at this time is based off the Orders Table only, and is used to derive the Orders Form.

Main goal: If the user ticks the VATable checkbox on the orders form, then that record's VAT% field must automatically be updated with the value in the field VATRate from the Constants Table.

Make sense?
Oct 3 '07 #5
Hi Luke
Thanks for the help, I will try to explain:

The Update Query updates the Orders Table VAT% Field from the Constants Table VATRate field if the check box VATable is ticked by the user.

The Constants Table contains the field VATRate, so that the VAT Rate can be changed in the table by the user, only having to change it in one place, using the update query to populate the changes throughout the rest of the Orders Table, those records where the the check box has been ticked by the user.

The Orders Query (select query) at this time is based off the Orders Table only, and is used to derive the Orders Form.

Main goal: If the user ticks the VATable checkbox on the orders form, then that record's VAT% field must automatically be updated with the value in the field VATRate from the Constants Table.

Make sense?
I believe I understand what you want to do. If you are ok with using VBA I can tell you really quickly how to do it. Otherwise, I'm working on a non-VBA solution atm.
Oct 5 '07 #6
MikeSA,

I've got to get going today and I wont be checking this till next week so I wanted to at least post to you what I've got in the hopes that it will help get you over the ledge. I have duplicated your setup and created a form that, when the checkbox is clicked, updates the VAT% with the VATRate from the constants table. The only problem with my solution so far is that since you have the form open, when you click the checkbox, it updates the Orders table, but then there is a write conflict with the form and the table (since the form isn't updated). You can just click "Drop Changes" to drop the forms changes and accept the update queries changes, but it's annoying nonetheless. I normally do all this stuff in VBA so I'm not familiar yet with how to get around that. Anyway, here is my solution so far:

Tables:

Orders
Fields: VATID, VAT%, VATable
Constants
Fields: ConstantID, VATRate

Queries:
OrdersQuery: a Select query on the Orders table

UpdateQuery:
--------------
Field: VAT%
Table: Orders
Update To: forms!frmorders.vatrate

Field: VATable
Table: Orders
Update To: Yes

Field: VATID
Table: Orders
Criteria: [forms]![frmOrders].[VatID]

Field: [forms]![frmOrders].[VATable]
Criteria: True
--------------

Forms:
frmOrders

Controls in Form:

VATID, VAT%, VATable (all from the OrdersQuery)
CurrentVATRate: unbound control: =DLookup("VATRate","Constants","ConstantID=1")

Macros:

UpdateRecord:
------------
SetWarnings: Warnings On=No
OpenQuery: Query Name=UpdateQuery, View=Datasheet, DataMode = Add
SetWarnings: Warnings On = Yes
------------


SUMMARY: The form has the Current VATRate listed on each record so that you can see what it is currently set to. The UpdateQuery uses that field to enter into the VAT% if the box is checked. In properties set the OnClick or AfterUpdate events for the checkbox to the UpdateRecord macro. The macro will run the UpdateQuery which checks for the checkbox in the true position and assigns the value based on the VATID that the form is currently on.

I hope this helps you get past your block!

~Luke
Oct 5 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Karaoke Prince | last post by:
Hi There, I have an update statement to update a field of a table (~15,000,000 records). It took me around 3 hours to finish 2 weeks ago. After that no one touched the server and no...
6
by: al | last post by:
Greetings, In the customers table in Northwind db, one can update PK (customerid) and all other fields in the same table. My question is how can you do this in the udpate stat. That is, if one...
2
by: aaj | last post by:
Hi all I have a continuous bound form and on each record is a tick box. The user ticks the boxes and these boxes define the batch. for future operations before they leave the page I count...
8
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
6
by: DP | last post by:
hi, i've got a film rental database., with a film table and form. i've got a checkbox in the form called 'available'. i;ve got a lblOnRent underneath. i just want it to say the film is on rent...
9
by: DP | last post by:
hi., i've got 3 tables, customer, film and filmrental. i've got a customer form, with a sub form at the bottom, which is a film rental subform. i've created an update query, which when a...
13
by: forbes | last post by:
Hi, I have a user that used the Query Wizard to create a query in Access. Now she claims that her master table is missing all the data that was excluded from the query. Can you create anything...
1
by: Regnab | last post by:
I've got a form where the user can edit the lookups available in the database. It consists of a list box of the various categories on the main form, a checkbox on the main form and a sub form which...
1
by: Euge | last post by:
Hi, I really hope someone will be able to help me with this one as I am sure im just missing something simple. I have an unbound form which has 20 yes/no unbound check boxes. The purpose of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.