473,395 Members | 1,521 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,395 software developers and data experts.

How to delete a row in a sub table when I key DEL on my keyboard?

Hi every body,
Please can somebody help me to find a solution how to delete a row in a sub table. Each time I try to delete the row, I got a pop up menu saying "You are about to delete 1 records. If you click yes you won't be able to undo the delete operation."

When I click yes, it shows that the record is deleted. But as soon as I refresh. the records is still there. It remains in the table.

Your solution please..
Jul 2 '13 #1
11 1571
zmbd
5,501 Expert Mod 4TB
Have you closed the form and re-opened?
Have you actually looked at the data tables?

One thing to note: In VBA, Refresh for a form is not the same as Requery. Refresh will not show any additions or deletions to a bound form's recordset whereas the Requery forces the form to go back to the data table and require the records.
Jul 2 '13 #2
I haven't written any code for the moment. I refresh it with F5. Please what is the VBA code to force to delete the row in the sub table?
Jul 2 '13 #3
I have closed and re-opened. Its the same. I've checked the relation ship as well, its ok. The recordset type have been change from dynaset to dynaset(inconsistent update). Still the same. I think we need some codes to force it to delete...
Jul 2 '13 #4
Seth Schrock
2,965 Expert 2GB
I think that to do this you would have to set the relationship to cascade delete. The only other option would be to create a button on a form and then code the deletion of the record in the related table first and then the main table's record.
Jul 2 '13 #5
Can't we use the event "On Delete"?
Jul 2 '13 #6
zmbd
5,501 Expert Mod 4TB
BACKUP YOUR DATABASE FILE!

Inconsistent update allows a whole host of ugly nasty stuff to happen and should not (IMHO) normally be used in a properly normalized database > Database Normalization and Table Structures.(the fact that it is in use at all points to some serious flaws in the database structure!)

I suspect that your "subtable" record is related to a record in one, or more, other table(s) that you are unaware of. You will need to go back thru your database design and fix all of this... more than likely from scratch...

Can't we use the event "On Delete"?
No, This is an event that is fired when a record is deleted, not a means to force delete.
Jul 2 '13 #7
zmbd
5,501 Expert Mod 4TB
BTW: Is this a split database? If so, what is the backend data source?
Jul 2 '13 #8
Seth Schrock
2,965 Expert 2GB
There is a Before Delete and After Delete event in Access 2010 (what version are you using?). However, these are linked to macros and I'm not sure how to delete a record in another table with a macro. I also find troubleshooting macros difficult.

@Z Wouldn't the Before Delete allow you to delete the record in the related table first and then allow the record to delete from the current table?
Jul 2 '13 #9
zmbd
5,501 Expert Mod 4TB
If you know which tables are related... and I can certainly pull that information out of the database via VBA; however, OP need to go in to table relationships and determine what is going on with the records before I'd provide any more help.

My fear here is that the data will become orphaned due to the use of inconsistent updates.

There is a very good reason behind why that record isn't going away as OP intends from that one single view of the data. Datasheets with subtables is a very limited means of viewing the information.
Jul 2 '13 #10
I have the Customers and Sales table which are related from one to many. The table Customers contain only the particulars of the Customers and the Sales table contain all the particulars of a sales transaction.

For example if during a Sales transaction where there are many articles being scanned and one have been scanned twice by wrong manipulation of the sales person, I clicked on the row which have been entered twice and key in Delete on the keyboard. It won't go away.

If there are 3 rows of data, the data won't become orpahned if I delete one. At least it should go away.

Can we write a VBA code like if there are more than one records(to avoid orphaned), force deletion?
Jul 3 '13 #11
zmbd
5,501 Expert Mod 4TB
For example if during a Sales transaction where there are many articles being scanned and one have been scanned twice by wrong manipulation of the sales person, I clicked on the row which have been entered twice and key in Delete on the keyboard. It won't go away
Normally in a POS when an item is scanned/sold, the item is removed from inventory in some manner. I would suspect that this is the underlying cause as to why you can not simply delete the duplicate sale... you need to add that item back to the inventory. Hence my position in post#10

SO within this thread, we can take a look at how to back out the "transaction" by streaching the question a tad by looking at the code behind the "sale." Understanding how that record is created is importaint to understanding how to remove the record; thus, "deleting" the record as requested. Otherwise we're looking at a new thread.


So, let's start with your database design at a high level view, what I have so far is:

tbl_customer : this table has the details behind your customer
tbl_sales : relates the tbl_customer to the product sold in some manner.
tbl_? : the other tables please and how they are related.

We then need to see the code and sqls behind the "Sales" transaction. It is realy very poor programming to not provide a "LineItemVoid" and "VoidSale" even the old mechanical cash registers could do that!

Before posting any of your code, sql, etc... please do a few things.
1) make sure you have a backup of the production database.
2) make a second copy for us to use as a development database
3) read thru >> Before Posting (VBA or SQL) Code.
4) read thru Database Normalization and Table Structures.
5) answer Post#8
6) which version of Access are you using

#3 and 4 are essential for you to understand as these are the core upon which most of the experts on-site start and it will help you to understand us.
#5 and #6 are essential in that any solution we may comeup with will vary based on these conditions.

Until we have this information, this thread is stalled.
Jul 3 '13 #12

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

Similar topics

11
by: suma | last post by:
Hello, I want to delete duplicate rows in a table when no primary key is defined. For eg: If we have table1 with data as below, Suma 23 100 Suma 23 100 I want to delete a row from this...
3
by: Jay | last post by:
Hi ! I am writing a page that displays a list of records in a table. Each row for each record. Each row has a checkbox associated with it. Does anybody know how to highlight a row when I click...
2
by: Jacky Luk | last post by:
Hi, I can't seem to find a way to delete all records of a table. I created my tables in MySQL Query Browser, then fill them up with VC++, but some records were incorrect, And I had to recreate the...
2
by: AP | last post by:
When developing, I have a production version that is being used by users, and as I develop, I periodically import the key data tables into my development version. There are about 4 tables and I...
2
by: Scott | last post by:
I have a macro set up to delete a table and then it imports an up-to-date copy of the table. Every once in a while the table gets deleted but the new one isn't imported, I assume the user is...
1
by: dstorms | last post by:
Hi folks, I am trying to set up my database to create a new record in one table when a new record is created in another. Since it is a one-to-one realtionship it certainly would be easier to put...
4
by: billa856 | last post by:
Hi, I want to know how can we set the value of Textbox = value of field in table when we select a value form combobx. example i have a table customer CID CNAME CSALARY 1 Billa ...
2
by: Kenxo | last post by:
Hello, I am new at scripting and having some problems with syntax on EXECUTE cmd I was traying to reset the primary key on an access db table but I thought it was easier to delete the table and...
3
by: bbatson | last post by:
Hello, Does anyone know how to avoid the 'delete table' warning that comes with a make-table query? As an example, I am referring to this message box: ...
13
by: ramprakashjava | last post by:
hi, i hav "java.lang.NullPointerException" error while Deleting table records using checkbox in jsp here i enclosed files help quickly plzzz.. ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.