Forms :: Delete Current Record
Jun 30, 2013
When I run this code to delete the form's current record, the Me.Requery throws error #3167 (Record is deleted) and leaves "#Deleted" in all of the fields.
Private Sub DeleteProfessional_Click()
Dim MyDatabase As Database
Dim rstProfessionals As DAO.Recordset
Set rstProfessionals = Form_Professional.RecordsetClone
If (rstProfessionals.RecordCount = 0) Then
MsgBox ("There are no Professionals to delete!")
[Code] .....
View Replies
ADVERTISEMENT
Dec 11, 2004
read other threads, read and used the codes, but it wont work.
i want: in a form, the record i´m looking at, when i press the "delete record" button, that the current record is removed from the table.
only thing i´ve achieved is deleting all the records (godbless backups!)
it all looks pretty clear but if you need more info just ask.
thanks
View 2 Replies
View Related
Jun 19, 2005
Hi guys. I made bounded maintenance form customer table in my access db.
But when I try to delete a record by clicking on the delete button I get
the following error. I be happy if some one help me delete record successfully. Thanks
Code:Run-time error '91'Object variable or with block variable not set
http://i5.photobucket.com/albums/y180/method007/deleteerror.jpg
pic ===>delete error
Code:Option Compare DatabasePrivate Sub cmdSearch_Click() Dim strStudentRef As String Dim strSearch As String 'Check txtSearch for Null value or Nill Entry first. If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!" Me![txtSearch].SetFocus Exit SubEnd If'--------------------------------------------------------------- 'Performs the search using value entered into txtSearch'and evaluates this against values in customerno DoCmd.ShowAllRecords DoCmd.GoToControl ("customerno") DoCmd.FindRecord Me!txtSearch customerno.SetFocus strStudentRef = customerno.Text txtSearch.SetFocus strSearch = txtSearch.Text 'If matching record found sets focus in customerno and shows msgbox'and clears search control If strStudentRef = strSearch Then MsgBox "Match Found For: " & strSearch, , "Congratulations!" customerno.SetFocus txtSearch = "" 'If value not found sets focus back to txtSearch and shows msgbox Else MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _ , "Invalid Search Criterion!" txtSearch.SetFocus End IfEnd SubPrivate Sub Command14_Click()'''On Error GoTo Err_CmdAdd_Click '''Me.DataEntry = True '''Me.CmdFilter.Visible = False '''Me.CmdShowAll.Visible = True '''DoCmd.GoToRecord , , acNewRec If DCount("*", "Customer") = 0 Then Me.customerno = 1 Else Me.customerno = DMax("Customerno", "Customer") + 1 Me.customerName.Value = " " End If '''Exit_CmdAdd_Click: '''Exit Sub'''Err_CmdAdd_Click: '''MsgBox Err.Description '''Resume Exit_CmdAdd_ClickEnd SubPrivate Sub cmdDelete_Click()Dim x As Variantx = MsgBox(" You are abut to delete " & Me.customerName & " from this table - proceed ? ", vbOKCancel)If x = 1 ThenWith myRS.Delete.MoveFirstEnd WithEnd IfEnd Sub
View 1 Replies
View Related
Nov 5, 2011
i insert a button that delete current record but i want when click on button the following message will not appear.
View 1 Replies
View Related
Apr 30, 2015
I have a table with fields for the year, dues, and a Boolean field that indicates whether or not its record is the current year record.
I have a form based on the table that is used to update the table.
My business rule is that only one record can have the "current year" field checked.
I am working with the Form_Before_Update event. What I would like to happen is if the person selects the "current year" check box and if there is already another record with its check box selected, my code will realize that the user has selected a second record and undo the check box and cancel the event.
Question: Looking for code that would check for the second record being checked and back out the user's check for that record?
Note: I have to account for not only the user clicking the record selector to try and save the record, but also the case where they check the box, then click on the "close form" button that I created.
View 5 Replies
View Related
Aug 7, 2015
I have a "Search" form that I am using to search through a query in a list box of all of my Customers. Once the record that I am wanting to view comes up I highlight it and click a "View" button to bring up another form with the customers full record. When this form is open I am able to update the customer information and add User's to it if necessary.
My problem comes after I click on my save and close button that takes me back to me search form. I want to close the search form and the error I get is "The record cannot be deleted or changed because table "tblUserProfile" includes related records." I click OK and get a SECOND error stating "You can't save this record at this time. MS Access may have encountered an error while trying to save a record. If you close this object now, the data changes you made will be lost. Do you want to close the database object anyway?"I have already made my changes and saved them in the form with the customer record so am not sure why I am getting an error when trying to close the Search form.
I am using an embedded macro on the view button. OpenForm with a Where condition [tblCustomerRecord]![Profile ID]=[Forms]![frmSearchCustomer]![Profile ID]
I have the listbox bound to the Profile ID. I have not been able to get the view button on the form to work without this step.Is there a better way to view a specific record from my listbox results?
View 1 Replies
View Related
Aug 3, 2013
i've designed a rental database (which seems to do what i want) - it's not perfect....
But i can't figure out how to accomplish this.
If i have a tenant, who has previously had a lease agreement on one of my properties, but then moves out, and then moves into one of my new properties, i can't seem to see how to get access to display just the new lease details.
I've attached a blank copy of the DB with some sample data to illustrate this.
you will see that test tenant has two leases, one expired lease, and one active lease, but on the main form it just shows the expired (original lease)....
View 3 Replies
View Related
Aug 14, 2013
How to do a 'Delete from ListBox' . My listbox is populated, but I want to be able to put a button on the form, select a record from the listbox and press the button to delete that record from the list.
I should add that this is an unbound listbox so it needs to be removed from the listbox and the table that is populating it.
Listbox is List22 the table that populates it is 'tblShootingTasks'
View 7 Replies
View Related
Oct 23, 2014
I am getting a problem with delete button..I want to delete record from subform and Table..
Table:Payroll
Subform:PayrollSearchQuery
Form:Payrollog
I am giving the code is ....
Private Sub Command58_Click()
'check existing selected record
If Not (Me.PayrollsearchQuery.Form.Recordset.EOF And Me.PayrollsearchQuery.Form.Recordset.BOF) Then
'confirm delete
[code]....
View 3 Replies
View Related
Mar 28, 2013
I'm very new to Access, Macros, and VBA. Basically I have a form in ContinuousForm format that has a delete button next to each record. It's been working fine for the past few hours but for some reason Access can't delete the corresponding record(s) (DeleteRecord) now. The button is run by a macro that's made by a wizard.
Also, is there an appropriate way to show code (if that is the term used) for Macros?
View 2 Replies
View Related
May 23, 2013
I am new to Access. I am using Access 2010. I have searched and found several articles on emailing the current record shown on a form but haven't been able to get any of them to work.
My goal is to have a user input information onto the form and then have one button the user will click that will save the current record, email the current record in pdf, and then close the form.
The form name is: frmCorrectiveActions. The unique identifier for a record is: Corrective Action ID.
The last coding I tried is below. I know something is wrong but have copied this code from another post about emailing forms so I'm not even sure what half of it means.
I am getting the message Run-time error '3075': Syntax error (missing operator) in query expression "Corrective Actions ID = 23' and when I hit debug this is highlighted: qry.SQL = strSQL
form Private Sub Email_Click()
Dim qry As DAO.QueryDef
Dim strSQL As String
Dim ReportQueryName As String
ReportQueryName = "qryCorrectiveActions"
Set qry = CurrentDb.QueryDefs(ReportQueryName)
[Code] ....
View 5 Replies
View Related
Jan 23, 2014
i have a database
two tables: Addresses, Instructions
One form_one subform: User form
The user form contains set of instructions for each company that we take care off, the sub-form has all of the addresses for the company, these come from the "Address" table, the two are linked via a field called "companyID" so the subform only displays the addresses for the current company being viewed on the form.
The problem is, on the subform there is a dropdown box called "administrator" and this is used to select the person who is looking after the company. Some of the companies have hundreds of addresses, so when i click the next record button on the subform I have to fill in the administrator again for every address for the same company. Is there a way using vba or a simple function to auto update all of the "administrator" dropdown boxes for that company based on the administrator I select for the first address.
ps access 2010
View 5 Replies
View Related
Jul 11, 2013
I have a form with command buttons to preview reports. For some reason only the first record shows up on the reports and not the current record.
View 10 Replies
View Related
Mar 24, 2015
I would like to disable the shortcut, CTRL - which allows a user to delete a record. A user accidentally deleted a record while typing in an email address that had an underscore in the email address. While trying to type it she must have hit the CTRL key instead of the Shift key follow by the -. She noticed the delete confirmation, but not thinking, pressed enter and thus confirmed the deletion of the record.
Other than telling her to pay more attention, how can I disable the shortcut in Access 2013?I tried using the Application.OnKey "^-", "" but I continue getting the error method or data member can not be found
View 2 Replies
View Related
May 31, 2014
I have made a navigation form that prints the current record out as a PDF and also the option to send the current record by email as a PDF. Both work perfect when you open the form outside the navigation form. But when you open it inside the navigation form, it does not print any of the information.
The problem is in the Query report, In the criteria box for field [RequsetID] it has
Code : [Forms]![FRMRequestForm]![RequestID]
(The above works outside the navigation form.)
I have also tried adding the navigation form name
Code : [Forms]![Main]![FRMRequestForm]![RequestID]
But none work.
View 4 Replies
View Related
Jun 4, 2014
I tried to follow the Allen Brown print the current record in the form and its not coming up. I can print all of the records but not the current.
View 3 Replies
View Related
May 30, 2014
I have a form that has 2 subforms. When I try to print the current file there are a few problems,
1) When you use the print option in File menu, and select "Selected Records" , it will always print the second record, no the one selected.
2) No matter how often I change the printer properties , it will not keep the paper size I request.
Is there a script I could use to set the size and print the current record ?
View 1 Replies
View Related
Apr 24, 2013
Currently, I have a database situation in which I am working in one database with data. If this data does not belong in this database I need to be able to take specific fields from the record and insert it into either a new table in a different database I have, or have it copied to a blank form that would accept it.
View 1 Replies
View Related
Mar 9, 2015
I have a database For customers of the company, when you open the main form through the search form , there are a filter . when you try to move between orders of this customer, there are a mssage (Asking you to approve of movement between the customer orders). to this point no problem, when you approval to move , cancel the filter on the main form with a stay at the current record (current customer).
View 14 Replies
View Related
May 8, 2013
I have a form which contains a subform. On this subform, the user will enter several lines of container ID numbers. If one of these containers has errors, they check a yes/no box and a pop up form opens for them to enter the details of the errors.
I want two fields that are populated on the subform to transfer information to the corresponding two fields on the pop up form. This works when only one container ID has been added to the subform. However, when there are multiple containers in the subform and the container with the errors happens to be the second or third record on the subform, the pop up form always transfers the information from the first record to those fields.
I also have the subform requerying when the check box is checked so that the information saves to the table and the focus does stay on the correct record but the pop up form still opens with the wrong information.
how to transfer the information from the record that the user is currently on?
View 4 Replies
View Related
Nov 27, 2013
This code shows current record number:
Code:
=[CurrentRecord]
This code shows total record number:
Code:
=DCount("[Category]","tblCategory")
How do I combine them in a textbox to say something like "8 of 10"?
View 1 Replies
View Related
Jun 5, 2014
I have created a navigation form with quick access to the forms and reports I use most often. The Navigation Form (which I named Control Panel) automatically lands on the Tutor_Information Form on a current record. However, I would like for it to open to a blank form instead while retaining the ability to access the current records. Individually, when opening the Tutor_Information Form from the Navigation Panel, it opens to a blank record.
I used a 2 step macro
1. OpenForm
2. GoToRecord - New.
How can I make it do the same thing when landing on the Navigation Form (Control Panel)? I am using Access 2013.
View 9 Replies
View Related
Aug 7, 2013
Lets say,
Form A has fields: ID, LN and FN
ID LN FN
1 A F
2 B G
3 C H
4 D I
5 E J
Form B has fields: ID, LN and TR
ID LN TR
1 A Y
2 B N
3 C Y
4 D Y
5 E N
I would like to be able to switch between these two forms and the form automatically set focus to the record that I was on the form prior. Meaning if I am on record 3 on Form A and navigate to Form B, I would like to automatically set focus to record 3. Is this possible?
A possible issue after this gets sorted out is what happens if with the same scenario above record 3 does not exits? is it possible in that instance to simply requery the form?
View 11 Replies
View Related
Jul 30, 2013
I have a Main form that has button that loads a new Pop Up form for entering new data that will display in the Main form. When all the data is entered I click on a button that Saves the data and exits the form and then runs Re-query on the main form returning to the record that was current before the requery.
I have the following code:
Private Sub cmdSaveTradeAndExit_Click()
DoCmd.RunCommand acCmdSaveRecord 'Save the current record
DoCmd.Close 'Close the current form
Dim CrId As Integer
CrId = Forms!frmTransactionMainActivePopUp.CurrentRecord
Forms!frmTransactionMainActivePopUp.Requery
DoCmd.GoToRecord , Forms!frmTransactionMainActivePopUp, acGoTo, CrId
End Sub
But I am getting the following error:
Run-time error '2498':
An expression you entered is the wrong data type for one of the arguments
And the following is in yellow in the debug:
Code:
DoCmd.GoToRecord , Forms!frmTransactionMainActivePopUp, acGoTo, CrId
View 4 Replies
View Related
Dec 2, 2014
I currently have a form that only shows data based on a specific record id. I have placed a list into that form though that has multiple record ID's listed ( It's a log). How do I get a List to Filter to just the Record ID that corresponds to the current form Record.
What I have are as follows:
A form that has client information : Address, phone numbers, Etc.
On that form I have Pages. one of the pages contains a List.
That List however contains information from multiple clients based on Point of Contact ( Call Log)
What I want is a way to narrow the List to only show those that corresponds to the Current Client Record.
Is this possible? If my approach is wrong, which is a better way?
View 1 Replies
View Related
Mar 21, 2013
I have a DB in Access 2007 which I'm having trouble with. I have a form, "Sub_Det_Frm", on which I would like to place a button to print the current record, (Primary Key is an autonumber "Employee Number") to a report "Sub_DetForm_Rpt".
I've used the instructions from, oops I can't show you the link! It's h(double t)p(colon)//allenbrowne(dot)com/casu-15(dot)html but I'm getting this error:
The expression On Click you entered as the property setting produced the following error: A problem occurred while Employee Details was communicating with the OLE server or ActiveX Control.
This error occurs when an event has failed to run because Microsoft Office Access cannot evaluate the location of the logic for the event. For example, if the OnOpen property of a form is set to =[Field], this error occurs because Access expects a macro or event name to run when the event is fired.
View 14 Replies
View Related