473,748 Members | 2,891 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

find and delete records in unrelated table

Hi,

Using MS ACCESS 2003, i have a form for entering data.
wih one object on the form (yes/no field) I want to inititiate vba code to
run if it changes.
I have no problem gettting it to update the table and append data (runs
macro which opens several queries) to it but if the field is changed to 'NO'
I want it to find and delete an associated record in a different table
(within the same database). The vba code samples I have found on the
interenet do not appear to work correctly. Can someone please point me in
the right direction and possibly provide sample code for findind and
deleting records according to change in particular field on a form for a
different table.

any help would be appreciated
TIA and regards
Birderman

--
Posted via a free Usenet account from http://www.teranews.com

Jul 24 '06 #1
2 5125

Birderman wrote:
Hi,

Using MS ACCESS 2003, i have a form for entering data.
wih one object on the form (yes/no field) I want to inititiate vba code to
run if it changes.
I have no problem gettting it to update the table and append data (runs
macro which opens several queries) to it but if the field is changed to 'NO'
I want it to find and delete an associated record in a different table
(within the same database). The vba code samples I have found on the
interenet do not appear to work correctly. Can someone please point me in
the right direction and possibly provide sample code for findind and
deleting records according to change in particular field on a form for a
different table.

any help would be appreciated
TIA and regards
Birderman
I would start by creating a SELECT query that finds the records I want.
Something along the lines of:

SELECT ...
FROM SomeTable
WHERE SomeField = Forms![MyOpenForm]![LinkingFieldOnF orm]

Then when you're sure it only selects the data you want, you can change
it to a delete query. (I'd make a backup of the tables involved before
testing... better to be safe than sorry).

That's the first step. then you'd have to write some code in the Click
event of the Checkbox

Private Sub MyCheckBox_Clic k()
If Me.MyCheckBox Then
docmd.setwarnin gs False
docmd.openquery "MyQuery"
docmd.setwarnin gs True
End If
End Sub

leave the SetWarnings out when testing. it shuts off the "You' are
about to ..."
HTH,
pieter

Jul 24 '06 #2
Hi,

Whilst this will work, I feel it is only a workaround as I was really
looking for a module level solution that can be done entirely as coded
subroutine. My preference for coded version is to reduce number of queries
stored in my database and to get experience of writing more vba code.

The samples in Access help for find and seek do not appear to function with
my database and they are not clearly explained.

Thanks for any help.
Birderman
<pi********@hot mail.comwrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
>
Birderman wrote:
>Hi,

Using MS ACCESS 2003, i have a form for entering data.
wih one object on the form (yes/no field) I want to inititiate vba code
to
run if it changes.
I have no problem gettting it to update the table and append data (runs
macro which opens several queries) to it but if the field is changed to
'NO'
I want it to find and delete an associated record in a different table
(within the same database). The vba code samples I have found on the
interenet do not appear to work correctly. Can someone please point me in
the right direction and possibly provide sample code for findind and
deleting records according to change in particular field on a form for a
different table.

any help would be appreciated
TIA and regards
Birderman

I would start by creating a SELECT query that finds the records I want.
Something along the lines of:

SELECT ...
FROM SomeTable
WHERE SomeField = Forms![MyOpenForm]![LinkingFieldOnF orm]

Then when you're sure it only selects the data you want, you can change
it to a delete query. (I'd make a backup of the tables involved before
testing... better to be safe than sorry).

That's the first step. then you'd have to write some code in the Click
event of the Checkbox

Private Sub MyCheckBox_Clic k()
If Me.MyCheckBox Then
docmd.setwarnin gs False
docmd.openquery "MyQuery"
docmd.setwarnin gs True
End If
End Sub

leave the SetWarnings out when testing. it shuts off the "You' are
about to ..."
HTH,
pieter


--
Posted via a free Usenet account from http://www.teranews.com

Jul 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
10805
by: Patrizio | last post by:
Hi All, I've the following table with a PK defined on an IDENTITY column (INSERT_SEQ): CREATE TABLE MYDATA ( MID NUMERIC(19,0) NOT NULL, MYVALUE FLOAT NOT NULL, TIMEKEY INTEGER NOT NULL, TIMEKEY_DTTM DATETIME NULL,
5
2231
by: Alex | last post by:
Hi, hi have a table with 2.5 million records which i try do delete. i have several constraints on it too. i tried to delete the records using delete but it does not seem to work. the delete runs forever. hrs... i cannot truncate it as it complains about foreign keys. What is the problem ? Thanks
6
3103
by: Paul T. Rong | last post by:
Dear all, Here is my problem: There is a table "products" in my access database, since some of the products are out of date and stopped manufacture, I would like to delete those PRODUCTS from the table, but I was not allowed to do that, because "there are records related with those PRODUCTS in other tables (e.g. in table "ORDER_DETAIL").
2
1759
by: Tim Tabor | last post by:
How can I delete records from a table with a criterion that depends on a value in an *unrelated* table? In other words, something like: DELETE tblPortfolioHistory.* FROM tblPortfolioHistory WHERE (((tblPortfolioHistory.Date)=.));
8
25073
by: John Baker | last post by:
Hi: Access 2000 W98! I have a table with numerous records in it, and am attempting to delete certain records that have been selected from it. These are selected based on the ID number in a different table. While I am using the tools in Access for query setup, its easier to show it on here using the SQL for the query, which is as follows( the table is ): DELETE .date, .,
2
8845
by: Cornelius Buschka | last post by:
Hi, we saw the following problem: We deleted all rows from a table B referencing table A (~500000 records). No problem, but the following try to delete all records from table A (~180000) lead to a "never ending" statement. We found out, that vacuuming table B after delete did the trick. It seems to us the database has to do scan thru deleted records on B while
6
11290
by: satish mullapudi | last post by:
Hi All, I am getting strange situation. These r the steps I have followed: 1. Created an EMPLOYEE table with around 14 fields & 688038 records. (so a large table indeed). 2. Tried to delete all the rows in the table using the traditional DELETE FROM EMPLOYEE stmt. It is taking around 53 secs to delete all the records. So I have done the below steps to make it fatster: (i) Create an empty file called No_Data.DEL in the C:\ drive....
7
9867
by: AccessHunter | last post by:
I am using the following code to find and delete records in a table. The logic will go through each record and if a duplicate row is found will delete it. I ran this code and it worked the first time. Its not deleting the rows when I tried the second time. I debugged the code and its actually going through the delete step but the row is not getting deleted as it did the first time. Please help. Thanks in advance. Function...
6
4089
by: scott.tang | last post by:
I'm experiencing a very strange problem. My application is MS Access front-end and MS SQL server back-end database. I have a SQL statement that deletes records from a table after an export process. The problem is occasionally when the delete statement is executed, these records no longer display on List Box (not even in the MS Access link table). But when close and reopen the form, those records reappear. It almost like MS SQL server...
0
8987
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9366
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9316
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2211
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.