How To Delete Current Record In Bounded Form?

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 Replies


ADVERTISEMENT

Error Updating Record In Bounded Form

Jun 19, 2005

Hi guys I am creating maintenance form to update and add new records to department table.
But when I try to edit department field in employee table.
(I get the following error.I get same when try to add new record.)

Error:
You cannot add or change a record becasue a related record is required in table department

http://i5.photobucket.com/albums/y1...gdepartment.jpg
==> pic of error errroupdatingdepartment

http://i5.photobucket.com/albums/y1...eletionship.jpg
===> timekeepingreletionship


I be happy if some expert help me how to update and add new record to department table successfully without the above error and without changing the db structure.
Thanks

View 2 Replies View Related

Delete Current Record Button

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

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 6 Replies View Related

Insert Button That Delete Current Record

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

How To Add Constraint To Access Bounded Form.

Jun 26, 2005

Hi everybody .I created a bounded form that allows user to enter the following fields information
to the sql server db that is linked to access .The fields are: Projectno, taskcode, taskdiscription
and total hours worked.

I want for example when a user tries to enter total hours work for a user (Hours in hours worked table) and
if he did not already enter wages of the employee for that particular project (amount in hourly wages table)
that user get a massage prompt and ask user to enter amount in to hourly wages table first. Possibly opening that form.

I be happy if some one help me add this feature to my form. Thanks


http://i5.photobucket.com/albums/y180/method007/constraint.jpg (table reletionships pic)

View 1 Replies View Related

Need Form For New Record/edit Current Record

May 12, 2005

I have a table called tblFinishedGoods. There are 3 fields in the table:Serial Number, Model Number and Location.

I would like to have a form that will take input from my barcode reader and input the data for the 3 fields, if the serial number is not already in the table.(I have this already working).
But now I would like the same form to also check the table for any serial number that is scanned in...and if it is in the table already, have it bring up the model number and location for that record.

I'm thinking maybe there is something I can do with Serial Number afterupdate. Basically I'm looking for a way to not require the user to input anything via a mouse or keyboard.

If the 1 form could accept the 3 scans:Serial Number,Model Number and Location, and either 1)enter a new record if that serial number isnt in the table or 2)find that the serial number already exists and overwrite the model number and location with whatever the next 2 scans are.

Thanks

View 2 Replies View Related

Delete Record Form

Feb 17, 2005

Okay, I want to make a form with a combo box that you can choose a record and click a button to delete it.

As of now I have the records in the combo box but when i can choose a record... i can't delete. and when i cant choose a record.. i can delete. Can anyone help me???? :confused:

View 11 Replies View Related

Delete A Record From A Form

Mar 19, 2006

How can I delete a record from a form?
I set Allow Datasheet view to yes, Allow Form No, and Allow deletions Yes.

Nothing happens. Perhaps A delete button could be added, but I don't know the code? I do not want to use the Datasheet view as the means of deletion.

View 3 Replies View Related

Delete Record On Continuous Form

Mar 2, 2006

I need to have a button on my continuous form that deletes the corresponding record... I used the wizard to create the button, but it doesn't seem to work...

Any Ideas?

View 4 Replies View Related

Delete Record In Form With Subform

Mar 15, 2006

I amd having trouble putting a delete cmd button in a form that has a sub form on it. The errror reads "the record cannot be deleted or changed because table "details" includes related records".

View 3 Replies View Related

Delete Record Button On Form

Jul 31, 2006

I have created a form and have put a delete button on it to delete the active record. This works fine in that it deletes the record as required.

However, at the top of the form is a combo box which can be used to find records. Once a record has been deleted, it is still listed in this combo box but as #Deleted!. Closing down the form and reopening it corrects this and the #Deleted! entry disappears.

How can I get around this? Possibly by making Access refresh the form after the delete command? If that's the correct solution, how do I do it?! Otherwise, is there a better way.

Thanks in advance,

Gary

View 6 Replies View Related

Creating Form To Target Current Record Open In Another Form

Apr 17, 2014

I have three objects a Main_Table , ClientDataForm and a MapForm all three share a common ClientID number

From that Main_Table I have created a ClientDataForm form which I enter all Data

From ClientDataForm I wish to create a button on it which runs a Macro that Saves ClientDataForm Record and then populates another form named MapForm with whatever record is currently open in Form One whether a newly created one or previous record.

How would I write this code for that button? Also why I would write it that way?

View 3 Replies View Related

How To Point A Form To The Current Record

Aug 17, 2006

I have a form in access that opens to the first record every time. This form will be constantly updated and i was wondering how i can set it, so that it opens up to a new record everytime you open the form.


Anyone know how to do this?

View 3 Replies View Related

Opening One Form From Another Using Current Record

Mar 25, 2005

I would like to create the following functionality on a form in my database:

When the form is open, and a record is displayed on the screen, I want to add a button that will open up a second form displaying information related to that record.

To be specific, I have a form called "Contracts". Each contract record contains a customer name in the field "Customers." I want to create a button labeled "Customer Details" that will open a new form, "ViewCustomers" displaying the record associated with the value entered in the "Customers" field for the current (displayed) record only.

I have been trying to use a hyperlink to a macro that uses "OpenForm," form name "ViewCustomers," but I don't know how to filter it down to just the current record.

I hope any of this makes sense. Any insight would be really helpful.

Thanks! -Matt

View 2 Replies View Related

No Current Record - Close Form

Jan 23, 2006

Hi,

on a form with several subforms i have ran into some trouble. I have the subforms use code to determine if a scrollbar is needed. As a recordselector I use a listbox on the main form.

When i close the mainform, it sometimes makes a popup box appear saying that there is no current record.

Sofar I have determined the following :

- Removing the code from the form, removes the error.

- The code is only executed when selected records in the listbox have related record(s)

- The error only occurs when the code is executed at least once and the last selected record has no related record(s)

I dont know if altering the code would have any success, cause it won't run anyway when I select the last record (with no related records).

I guess moving the code to another section would be better, but I've tried other options like 'on focus' etc, but could not find one that responded.

HELP PLZ :)


Private Sub Form_Current()
On Error GoTo Error

'kijken of verticale scrollbar nodig is
maxRegels = 14

Dim rstCount As DAO.Recordset
Set rstCount = Me.Recordset
If rstCount.RecordCount > maxRegels Then
Me.Form.ScrollBars = 2
Else
Me.Form.ScrollBars = 0
End If

Error:
If Err.Number <> "0" Then
Else
MsgBox Err.Number & " " & Err.Description
End If
Exit Sub

End Sub

ps. I've tried to catch err.Number = "3021" in the Error: section, but without success

View 5 Replies View Related

Email Current Form Or Record

Oct 19, 2007

I'm really new at this Access database, but I've managed to create a database, tables, forms, macros, report and a switchboard, most of which work. Printing the current form command button works great.

I really need to email the current form or record, but can't seem to figure it out. I can email the report using the snapshot format, which is what I'm after, but it includes every record. If I email the form, the format has to be chosen and it doesn't look like the report.

Can someone help me with this? Thanks so much, Jolene

View 3 Replies View Related

Add Record From Current Form To A Table?

Aug 26, 2013

I have a database that includes the following items related to my question:

- Tables: tblCases, tblPeople, tblPeoplePerCase,

- Forms: frmCases, frmPeople, subfrmPeoplePerCase, frmSearchPeople

What I'm trying to do is automate the process of adding a selected person to a particular case. What I'm thinking is that frmCases (which includes subfrmPeoplePerCase) will include a button to add a person to the case. Once clicked, frmSearchPeople would open. Once a person is selected and frmPeople displays their information, a button would then be displayed/enabled on frmPeople to add them to the current case in frmCases. Once this button is clicked, it would display a message box asking to confirm if PersonID should be added to CaseID. If confirmed, the information is then appended to tblPeoplePerCase (which includes PersonID, CaseID). The user is then brought back to frmCases and the subfrmPeoplePerCase displays the newly related information.

View 1 Replies View Related

Getting ID Of Current Record Displayed On A Form

Jun 14, 2012

I am having trouble getting the ID of the current record displayed on a form. The code I have written is this:

Code:
Dim ProjID As Long
ProjID = Forms![ProjectDetailsAll].CurrentRecord

The problem is that this code returns the record number relative to other records (so, this record is number 2634 of 2634). However, I am trying to get the ID of the record, which is an autonumber and is not the same as the record's order amongst other records. There have been record deletions ahead of this record, so the ID might be 3096 even though CurrentRecord tells me that this record is number 2634. Is there another way of writing this to get what I need?

View 3 Replies View Related

Modules & VBA :: Delete Record From Unrelated Form

Jul 2, 2015

I have a form based on Table A. When a yes/no tick is clicked in the form, I want to delete a record from Table B. The tables are joined by ID numbers.

View 1 Replies View Related

Requery Form And Goto Its Current Record

Apr 19, 2006

I'm requerying a form after an update.

I would like to have the form to be set to its current record when being requeried. How can I easily achieve this?
I've seen things about recordsets, I'm working with ADP (based on SQL Server) and don't know or all DAO events will help me.

View 3 Replies View Related

Copying The Current Record On A Form To Another Table

Dec 17, 2007

is there an easy way to copy the current record on a form when clicking a command button such that a snapshot of that record is copied to a table for archiving purposes?

the table has about 120 columns so it is cumbersome to write an Insert Into sql statement within VBA code.

what i am attempting should be quite straightforward...i just want to take the current record in its entirety that is from a single table and append it to another table of the same structure.

any help would be appreciated!

View 12 Replies View Related

Printing Current Record On Form And Subform

Oct 21, 2006

I currently am trying to print the current record that I have selected on my form and the subform that I have on the same page. If I try to print selected record it will only print out the main form correctly and will print out the first record on the sub form. I have tried to make a reprot of the current form and it only will do the main form and nothing from the sub form. I am willing to try whatever method would work in getting this to work. Thanks

View 2 Replies View Related

Modules & VBA :: Save Current Form Record Only As PDF

Jan 17, 2014

I'm using: DoCmd.OutputTo acOutputForm, "Frm_EL_PL_Bulk_Send", acFormatPDF, outputFileName1...To save a form as a PDF. The issue is, it saves all the records in that set in continuous form, and I'm trying to get it to only save the record its on.

View 3 Replies View Related

Modules & VBA :: Form Won't Go To New Record On Current Event

Jun 3, 2015

I have a form with a subform. In the form's On Current event I have the subform's visible property set to false. There is a button that when clicked sets the subform's visible property to true. I want the subform to go to the first control in a new record which is a combo box. the subform is a multiple items form. I have tried the GoToControl in the subforms OnCurrent event, but it is not working. I get an error saying the database cant find a third form.

View 4 Replies View Related

Print Single Record Based Upon Current Form

Apr 6, 2006

I need to Print a single record from a form but using a report layout.

I have created the form and created a report. A button on the Form kciks off the print but I get all records rather than just the one shown on the Form. Whats a really simple way of just selecting the Current record.

Where do I put an instruction saying print only this record:confused:

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved