Deleting a record deletes item from combo box's underlying table

MS Office Access

    Next

  • 1. Problems with Combo Box
    My database has 28 "Station Sts". In the combo box, users can do a search on the location (each has a unique asset number), but if the wrong one comes up, they cannot move down the list and select the next station st. My code is: Private Sub btnSearch_Click() Me.txtStreetName.SetFocus DoCmd.FindRecord cboSearch1, , , acSearchAll, , , True End Sub Private Sub cboSearch_AfterUpdate() Me.btnSearch.SetFocus End Sub I am not sure if the problem is here, or with the select query, and would appreciate some help. Thanks
  • 2. Trouble with Query Statement
    I keep getting the following error with the code below: runtime error '13'; Type mismatch. Set rst = CurrentDb.OpenRecordset("SELECT tblCaseInfo.CaseID, tblCaseInfo.DHSNo, tblCaseInfo.Region, tblCaseInfo.DHSAttny, tblCaseInfo.CaseName, " _ & "tblAction.CaseID, tblAction.Actn, tblStatus.CaseId, tblStatus.ClosedDate, tblStatus.StatusRptNotes " _ & "FROM (tblCaseInfo INNER JOIN tblAction ON tblCaseInfo.CaseId = tblAction.CaseID) " _ & "LEFT JOIN tblStatus ON tblCaseInfo.CaseId = tblStatus.CaseId " _ & "WHERE ((tblStatus.ClosedDate) Is Null);") I tested the above SQL statement as a regular query and it works. Can anyone tell me where I went wrong in the proper VB phrasing of the statement above? FYI, I am trying to pass information to an Excel spreadsheet. If you need more of the code to answer, let me know. TIA S. Jackson
  • 3. Create new record and move to it in the form load
    I may be doing this wrong, but there it goes. I open my main input form from a new issue form, with an openargs of 1. Here is the form load code on the main input form: Private Sub Form_Load() If Me.OpenArgs = 1 Then Call createnew_issue Me.Issue_Reference_Number = Forms!frmnewissue_setup.Text5 Me.division = Forms!frmnewissue_setup.Combo3 Me.Year = Forms!frmnewissue_setup.Text9 Me.Combo206 = Forms!frmnewissue_setup.Combo11 'MsgBox "We have prepopulated some fields, but you can change them if you need to." Me.Detail.Visible = True DoCmd.GoToRecord , , acLast DoCmd.Close acForm, "frmnewissue_setup" 'Me.OpenArgs = 0 End If DoCmd.Maximize End Sub and createnew_issue sub is: Public Sub createnew_issue() DoCmd.GoToRecord , , acNewRec [Issue Entry Date] = Now() End Sub So I am trying to make sure the user sees the new record they created on the first form. The form currently opens on the first record in the database, but if I click on the goto last button I created, I can see the new record (hence why I tried the docmd.goto last above). Do I have to move records after the Form Load has completed? Thanks -- Yours Fictionally, Biggles
  • 4. Error: You cannot go to specific record
    Hi, I am trying to add records in a form using standard code: Private Sub Command29_Click() On Error GoTo Err_Command29_Click DoCmd.GoToRecord , , acNewRec Exit_Command29_Click: Exit Sub Err_Command29_Click: MsgBox Err.Description Resume Exit_Command29_Click End Sub However, when I try to add record it gives the following error: You can't go to specific record This prevents me from getting the add button functional. Any help is appreciated. Thanks
  • 5. Inquire and Update on Form
    How do you setup a record ID field on the form to be able to inquire on the record without no other field entered, even if any other field is marked as required. Also, but the same token, how do you prevent this ID field from being *CHANGED* in the table within the BE file, when you enter a value for the field in the FE file to inquire? -- Sincerely, Ronald R. Dodge, Jr. Master MOUS 2000

Deleting a record deletes item from combo box's underlying table

Postby U3VzYW4gTA » Thu, 26 Jul 2007 06:16:04 GMT

A strange problem has recently appeared -- when a user deletes a contact in a 
contact data entry form, items from two combo boxes on the form (that draw 
their values from two separate tables) are deleted from their respective 
tables. The delete button was created with the Wizard, and contains the 
following code.

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

I am suspicious of corruption, because I recently could not get an external 
report that was correct in my development database to import properly (the 
report changed when imported). I finally decompiled, recompiled, and 
compacted, and the report imported properly.

Should I decompile again? Is there something else I should look at? (I tried 
locking the two controls, but that of course meant that the selections did 
not write to the main contacts table, and I need to have them there.)

Any help would be appreciated.

-- 
susan

RE: Deleting a record deletes item from combo box's underlying table

Postby QW5keSBIdWxs » Thu, 26 Jul 2007 23:56:02 GMT

Hi Susan

This can happen by setting certain properties although you wouldn't normally 
want to.

I presume the form has an underlying query and that this query gets data 
from the contacts table and the 2 tables used by the combo boxes.

When a record is viewed in the form and deleted Access has to decide whether 
to delete the whole record, ie all items from all tables or just to delete 
the items in the contacts table.

To only delete contact info it has to know that the other items are just 
"looked up" and the only way it can know this is if the query joins to the 
"look up" tables using a primary key.

So, check the "look up" tables to see if they have a primary key and that 
this is the column the query uses when joining from the contact table.

If this solves the problem I would also check the following...

Go to the form's property sheet - data tab - Recordset Type should normally 
be Dynaset (yours might be Dynaset (inconsistent updates))

Also, what happens if you go into the form and use one of the combo boxes to 
change one of these attributes?

Does it just change that contact or does it change the attribute value in 
the look up table itself? BACKUP DATABASE before checking this!!!

hth

Andy Hull






Similar Threads:

1.Deleting a record deletes item from combo box's underlying tab

thanks, Andy. I checked the primary keys on the two combo box tables: in one 
the primary key was the same as the column in the contacts table; in the 
other it was not, so I changed the PK so it matched the column in the 
contacts table.

This change did not solve the problem. The forms recordset type is Dynaset 
(Inconsistent Updates). I checked changing the value in the combo box to see 
what the change affected. I could only do this in one of the combos (I had 
the other set to Limit To List). It only affected the record as it was 
recorded in the contacts table -- not in the lookup table. (I changed that 
one to Limit to List also, after doing the test.)

Any other suggestions? (the weird thing is that this is only a recent 
problem. In past months, there have been a number of records deleted without 
this unintended side effect.)
-- 
susan


"Andy Hull" wrote:

> Hi Susan
> 
> This can happen by setting certain properties although you wouldn't normally 
> want to.
> 
> I presume the form has an underlying query and that this query gets data 
> from the contacts table and the 2 tables used by the combo boxes.
> 
> When a record is viewed in the form and deleted Access has to decide whether 
> to delete the whole record, ie all items from all tables or just to delete 
> the items in the contacts table.
> 
> To only delete contact info it has to know that the other items are just 
> "looked up" and the only way it can know this is if the query joins to the 
> "look up" tables using a primary key.
> 
> So, check the "look up" tables to see if they have a primary key and that 
> this is the column the query uses when joining from the contact table.
> 
> If this solves the problem I would also check the following...
> 
> Go to the form's property sheet - data tab - Recordset Type should normally 
> be Dynaset (yours might be Dynaset (inconsistent updates))
> 
> Also, what happens if you go into the form and use one of the combo boxes to 
> change one of these attributes?
> 
> Does it just change that contact or does it change the attribute value in 
> the look up table itself? BACKUP DATABASE before checking this!!!
> 
> hth
> 
> Andy Hull
> 
> 
> "Susan L" wrote:
> 
> > A strange problem has recently appeared -- when a user deletes a contact in a 
> > contact data entry form, items from two combo boxes on the form (that draw 
> > their values from two separate tables) are deleted from their respective 
> > tables. The delete button was created with the Wizard, and contains the 
> > following code.
> > 
> > DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
> > DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
> > 
> > I am suspicious of corruption, because I recently could not get an external 
> > report that was correct in my development database to import properly (the 
> > report changed when imported). I finally decompiled, recompiled, and 
> > compacted, and the report imported properly.
> > 
> > Should I decompile again? Is there something else I should look at? (I tried 
> > locking the two controls, but that of course meant that the selections did 
> > not write to the main contacts table, and I need to have them there.)
> > 
> > Any help would be appreciated.
> > 
> > -- 
> > susan

2.Outlook Items events don't give Delete event when you delete last item in items

The Outlook ItemsEvents interface has 3 methods:

  ItemsEvents = dispinterface
    ['{00063077-0000-0000-C000-000000000046}']
    procedure ItemAdd(const Item: IDispatch); dispid 61441;
    procedure ItemChange(const Item: IDispatch); dispid 61442;
    procedure ItemRemove; dispid 61443;
  end;

The ItemRemove event is not fired when the last item from an Items set is 
removed. It tells when when the 3rd last one is removed. The 2nd last one. 
But not the last one.

And of course, i then don't know that the last one is gone - so i try to 
access it - and get an error. 


3.Deleting text in a combo box to delete row in N:N table

4.Deleted data from Combo Box deleted table data.

I deleleted duplicate data in two of my combo boxes (in query).  When I 
finished, I saved this on my backup.  I went back in and noticed that about 
90% of my table was deleted.  

I stopped working on my database onthe hard drive and disc.  Is there any 
hope that the data can be recovered after both files were closed and saved?  
I work at a large University with a good IT department.  Do you think I 
should contact them?  

I spent 3 weeks entering this data from last year's results...and had JUST 
finished.


5.Can I delete a number of items in the deleted box,at once not all

I have a lot of old e-mails in my deleted box like form 2001, I am tired of 
doing it one at a time.  Some I do want to keep for a while.  Is there a way 
I can just mark the ones I want gone forever, and keep the rest, without 
doing it one at a time.

6. Deleted item appears in "Deleted Items" every time OLK2002 is star

7. Deleted Items in a Combo Box

8. delete item from a combo box



Return to MS Office Access

 

Who is online

Users browsing this forum: No registered users and 1 guest