473,387 Members | 2,436 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,387 software developers and data experts.

Delete button for continuous form from searching form

Hi there

I have an access form that allows the user to browse records (< and > buttons) sorted by another field within that table (eg, all entries under a staff group, all entries under a student group).

I have added a delete button to the form using code supplied by another user of the forum (thanks to PEB):


Expand|Select|Wrap|Line Numbers
  1. Dim rst As Recordset
  2.  
  3. Set rst = Me.RecordsetClone
  4. rst.Delete
  5. rst.Close
  6. rst.Requery

From what I can tell it works great on the first record, but any subsequent records I get the 'no current record' popup. I need it to work multiple times if other entries need to be deleted. (I also want it to give an 'are you sure yes/no' popup but that's a different issue)

Can anyone help or is more info required? :)

Cheers
Gareith
Mar 25 '07 #1
5 1957
MMcCarthy
14,534 Expert Mod 8TB
Hi Gareith

The following will give you the popup message ...

Expand|Select|Wrap|Line Numbers
  1. Dim rst As Recordset
  2. Dim rslt As Integer
  3.  
  4. Set rst = Me.RecordsetClone
  5. rslt = Msgbox "Are you sure you wish to delete this record?", vbYesNo
  6. If rslt = vbYes Then
  7.    rst.Delete
  8.    rst.Close
  9.    Me.Requery
  10. End If
  11.  
Also you were requerying the recordset and not the form. See how this works now. It may require further tweaking.

Mary
Mar 26 '07 #2
Thanks Mary!

The popup code works great.
The outstanding issue now was if the returned filter records was 1 of 20 then it showed the next record fine, but if it was 1 of 1 then the code failed because the only record had been deleted. I've just made the delete record routine exit the form completely which is working fine with the users.

Thanks again :)
Gareith
Mar 26 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Thanks Mary!

The popup code works great.
The outstanding issue now was if the returned filter records was 1 of 20 then it showed the next record fine, but if it was 1 of 1 then the code failed because the only record had been deleted. I've just made the delete record routine exit the form completely which is working fine with the users.

Thanks again :)
Gareith
You're welcome.
Mar 26 '07 #4
NeoPa
32,556 Expert Mod 16PB
Very picky point, I know, but you probably want the rst.Close line outside of the If section.
Expand|Select|Wrap|Line Numbers
  1. Dim rst As Recordset
  2. Dim rslt As Integer
  3.  
  4. Set rst = Me.RecordsetClone
  5. rslt = Msgbox "Are you sure you wish to delete this record?", vbYesNo
  6. If rslt = vbYes Then
  7.   rst.Delete
  8.   Me.Requery
  9. End If
  10. rst.Close
  11.  
Mar 27 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
Good point Ade.
Mar 27 '07 #6

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

Similar topics

4
by: Eric | last post by:
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works fine, however, when the checkbox is only field...
3
by: Steve Lefevre | last post by:
Hey folks - I have a form for scanning in packages as they arrive. It's a continuous form, with one field to hold the scanned case number. On the row I also have a button to delete the record,...
4
by: Elliot M. Rodriguez | last post by:
I have a Delete button in my datagrid. I'm attempting to add some code confirming whether the user wishes to really delete the item or not. The confirm pops up, but I cannot suppress the...
3
by: vcornjamb | last post by:
Hello, I am developing a web form that contains some buttons and a data grid which has as its last column link buttons that will delete the data associated with that row. Everything works fine,...
2
by: jim Bob | last post by:
Hi, I have a form with a list box that shows the contents of a table and managed to create an add record button with the wizard. (DoCmd.GoToRecord , , acNewRec) Now i want to make a delete...
12
by: Fuzzy Logic | last post by:
Hey, I've built a continuous form with a delete button on each row using DoCmd.RunCommand acCmdDeleteRecord. (Is there a better way?) Now the problem is that when I click on a button on a...
1
by: bazubwabo | last post by:
hi everybody, there is someone who can help me to find out how to create a delete button .Indeed,I have then 2 buttons, one for insert(works well),second one is therefore for to delete. You can...
3
by: bluez | last post by:
I want to design a webpage where user can search the data from the database and list out the related records. Each of the record got a delete button which allow user to delete the record. ...
1
by: faisalabad | last post by:
Hi everyone newb, i am connecting to database then accessing a table and printing whole table on php page as table with "delete" button at the end of every row (so same delete button being printed...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.