From Subform: Delete record after Requery and Save

Mmattson

Registered User.
Local time
Today, 08:23
Joined
Oct 28, 2002
Messages
46
I have some code that runs some code to add a foreign key to a sub-sub-form. To refresh the foreign key data I also run a requery. The code also saves the record. The sub-sub-form is now reset back to the first record of the related records.

  1. The problem I have is that regardless of which line's Delete button I click, the first record gets deleted - not good.
  2. If I select into the record, then click a delete button, it works correctly. However, if I back out (check NO) after selecting a record and click delete, I am presented with only the selected record and the following records - even though all are still there. This will freak out my users. I have tried requery , but either I am doing something wrong or it it the wrong way to do it. How do I show all records after this process?

Code:
Private Sub delLine_Click()
On Error GoTo Err_delLine_Click

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

Exit_delLine_Click:
    Exit Sub

Err_delLine_Click:
'    MsgBox Err.Description
     Resume Exit_delLine_Click

' Requery to refresh data   
     Me.[Conferences subform1].Form.Requery

End Sub


Private Sub Statement_Enter()
'   apply foreign key upon entering subform field
    Me.TradeAssocID = Me.fkTradeAssocID
End Sub

Private Sub Statement_Exit(Cancel As Integer)
'   Save record upon exit of subform field 
'   Run update query to add key to bridge table
'   On Error Resume Next
    DoCmd.RunCommand acCmdSaveRecord
    CurrentDb.Execute "Qupd", dbFailOnError

End Sub
 
dispite that it was prtty diffcult to get along with wat you'r saying but i will try to assume, better than leaving you in a dazzle :
1 - Either you have the button not placed in details section of the form OR you have another event you set and cant figure where that moves your record selector to first record

Hints:
* check button_getfocus , form_current , form_enter , form_exit
** try switching to : DoCmd.RunCommand acCmdDeleteRecord as your issued commands go way back to ms access 95

2 - This is an access default procedure , however i wonder why wouldnt requery work , are you talking about requering sub / sub form ? or main ?
Hints :
* did you try DoCmd.GoToRecord , , acFirst 'it would lead to navagate to 1st record
** if you are trying to requery a sub (sub) form then try using :
Forms!MainFormNameHere!SubFormNameHere.Requery
Or
Forms!MainFormNameHere!SubFormNameHere!SubSubFormNameHere.Requery

Best regards.
 
Thanks for the response. I tried your listed items where I hadn't already tried it. Go ahead and "Dazzle" me...:p

1 - Either you have the button not placed in details section
I checked this - Not the answer

another event you set and cant figure where that moves your record selector to first record
This is what I think, but can't find it while reviewing code.

DoCmd.RunCommand acCmdDeleteRecord
Did this, already - Not the answer

Forms!MainFormNameHere!SubFormNameHere.Requery Or Forms!MainFormNameHere!SubFormNameHere!SubSubFormN ameHere.Requery
Tried this based on your tips - Not the answer.
 
Quote:
another event you set and cant figure where that moves your record selector to first record
This is what I think, but can't find it while reviewing code.

try to search all three forms for "bookmark" or "DoCmd.Gotorecord"

Quote:
Forms!MainFormNameHere!SubFormNameHere.Requery Or Forms!MainFormNameHere!SubFormNameHere!SubSubFormN ameHere.Requery
Tried this based on your tips - Not the answer.

You are trying to convince us that there is a problem with your access ?
I highly suspect malcoding :S
 

Users who are viewing this thread

Back
Top Bottom