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

Access form delete query not working but no error message.

Hi everyone.

I'm having some bother with a delete query on a form I've built.

On the form is a text box which contains a unique ID. I would like to be able to delete the whole record that corresponds to that unique ID from the table that it is linked to.

So far my code looks like this:

Expand|Select|Wrap|Line Numbers
  1. StrQuery = "Delete FROM TblSubmissions " & "WHERE tblSubmissions.[Unique ID] = " _
  2. & Forms("Submit").TxtID & ";"
I've also put in a plain message box after the query to show me it's triggering. The problem is that the sub appears to be working, however the table isn't altered. There aren't any error messages being advised and the message box triggers away fine but the record isn't being deleted.

The Unique ID is lifted directly from the table when the form loads so it's not an error inputting it.

It has me stumped. Any advice you can provide would be much appriciated.
Jun 27 '13 #1
4 2423
Rabbit
12,516 Expert Mod 8TB
If that's all the code you have so far, then it doesn't match your description of the problem.

1) We have no idea how it's triggered.

2) There's no message box in your code that you posted.

3) All you have there is a string, I don't see where you run the query.
Jun 27 '13 #2
Thanks for getting back to me. I'll try to clear things up.

The delete query will need to be run in a few different situations so at the moment I just have it triggered from a command button.

As it doesn't form part of a real sub yet I just truncated the code. Here's the full sub as it stands:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command70_Click()
  2.  
  3. Dim StrQuery As String
  4.  
  5. StrQuery = "Delete FROM TblSubmissions " & "WHERE tblSubmissions.[Unique ID] = " _
  6. & Forms("Submit").TxtID & ";"
  7.  
  8. MsgBox StrQuery
  9.  
  10. MsgBox "Test", vbOKOnly + vbExclamation, "Incorrect Reference"
  11.  
  12. End Sub
If it helps the output from the MsgBox is:

Delete FROM TblSubmissions WHERE tblSubmissions.[Unique ID] = RCI1;

RCI1 is the unique referrence that I want to use to delete the record.

Is there anything else I can tell you?

Cheers.
Jun 28 '13 #3
Thanks Rabbit but I've figured it out. I realised I was making things far more difficult than was needed.

Instead I've just built the query normally then called it from within the code.

Couldn't see the wood for the trees on that one!
Jun 28 '13 #4
Rabbit
12,516 Expert Mod 8TB
Glad you got it working.

But for future reference, the reason it didn't work but you got no error message is that you never ran your query code.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL StrQuery
Had you run it, you would have gotten an error. Since RCI1 is a string, you needed to surround it in quotes.
Expand|Select|Wrap|Line Numbers
  1. StrQuery = "Delete FROM TblSubmissions " & "WHERE tblSubmissions.[Unique ID] = '" _ 
  2. & Forms("Submit").TxtID & "';" 
Jun 28 '13 #5

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

Similar topics

2
by: Uttam | last post by:
Hello, In my application, I need to create temporary files, use them as sources for queries which in turn populate forms. When a button is clicked, I need to delete these temporary files,...
8
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: ...
1
by: iam247 | last post by:
Hi I am a relative beginner with SQL and ASP. With some help after previous posts I have a page which successfully requests querystrings from another page and deletes a record from an access...
4
by: TJS | last post by:
When trying to delete a row from a datagrid I get this error on every record regardless of record selected to delete. "Index 7 is not non-negative and below total rows count." there are 8 rows...
4
by: Mark | last post by:
Hello - I receive the error message: System.Runtime.InteropServices.COMException: The remote procedure call failed. when I open an Excel file using from an ASP.Net page. Imports...
3
by: Kevin M | last post by:
I have one table and have created a form from that table. Also, I have created a delete query. I want to but a button on the form which will delete all records from the table; however, I cannot get...
4
by: atiq | last post by:
i have used a combo box on a form linked to a query. the user is to select a value from the combo box and this click 'Find'. But on an old occasion where the user has forgotten to select a value from...
2
by: bruce24444 | last post by:
I have a field in a table set to "Required". When a user is inputting data via a form and if they leave this field blank, Access automatically returns the following error message: The field...
8
by: Trevor2007 | last post by:
Hi, I have 2 tables and The VMSU-ILt-Main Table contains info about a person on the main form, the VMSU-ILT-Sub Table contains info about the subform on the main form. they both have as ehe...
7
by: kpresidente | last post by:
Hello all, I'm trying to transfer the value of a control on an Access form to an Excel worksheet using VBA. The Access form is a single form with all the controls disabled, so that data is "read...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.