+ Reply to Thread
Results 1 to 8 of 8

VBA code to delete XLSX database record

  1. #1
    Registered User
    Join Date
    03-23-2023
    Location
    Brazil
    MS-Off Ver
    2010
    Posts
    2

    VBA code to delete XLSX database record

    Hello
    I'm using an XLSX database and I'm having trouble finding a code to delete a record.
    Can anyone help me with this?
    (Sorry for the spelling, I'm Brazilian and I don't write English very well)

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: VBA code to delete XLSX database record

    For a workbook to contain code/macros it has to be saved as macro enabled with an extension .xlsm not .xlsx
    see big yellow banner 'how to upload your workbook' you will then stand a better chance of getting help and a solution.
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  3. #3
    Registered User
    Join Date
    03-23-2023
    Location
    Brazil
    MS-Off Ver
    2010
    Posts
    2

    Re: VBA code to delete XLSX database record

    Quote Originally Posted by torachan View Post
    For a workbook to contain code/macros it has to be saved as macro enabled with an extension .xlsm not .xlsx
    see big yellow banner 'how to upload your workbook' you will then stand a better chance of getting help and a solution.
    I use the XLSX file as a database to make queries and changes via SQL command.
    The macros are in an XLSM spreadsheet

  4. #4
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,150

    Re: VBA code to delete XLSX database record

    You are probably using ADO and SQL to query the "xlsx" file. Unfortunately, ADO does not support deleting records when the database is an Excel file. You can only write a "blank record" on a record that you actually want to delete.

  5. #5
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: VBA code to delete XLSX database record

    As Haluk mentioned, the record cannot be deleted. But you can use an additional column in the table, such as Deleted, and when you need to delete a record, mark that record with True in the Deleted column. This, of course, involves changing SQL queries, as you will have to additionally filter the data by the Deleted column.

    Artik

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: VBA code to delete XLSX database record

    Am I misunderstanding the problem - surely the simplest is to save the .xlsx as .xlsm then write the 'deletion' macro in the same file rather than 'going around in a complex circle' of disjointed processes.

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBA code to delete XLSX database record


    As an « XLSX database » is a non sense … Better use an Access database file for example …

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,456

    Re: VBA code to delete XLSX database record

    @ajwebtv01: you need to upload examples of both files with enough (redacted) data to simulate the processes and requirement.

    As you have an .xlsm file with the query code, I would have thought it fairly straightforward to write VBA code to find and delete records in the .xlsx file. No body is going to guess at a solution based on the detail provided so far.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ado- delete record from xls or xlsx
    By chronjy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-29-2021, 01:06 AM
  2. Delete record in access database with excel VBA
    By Eureka in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-14-2013, 02:15 PM
  3. Replies: 1
    Last Post: 01-03-2013, 01:13 AM
  4. VBA Excel Code to Insert New Record into MS Access Database
    By Vladamir in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-28-2012, 09:15 AM
  5. Update/Delete a Record in an Access 2010 Database using Excel VBA
    By tomlancaster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2012, 12:36 PM
  6. Delete a record from a database
    By Aland2929 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-01-2010, 06:21 PM
  7. MS Access record delete from excel database query results
    By sdnicsm in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 01-23-2005, 03:55 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1