refresh subform after deleting record

supa_sumo

Registered User.
Local time
Today, 00:18
Joined
Jul 1, 2004
Messages
48
Ok heres the situation, I have one form(frmBikes) that i use to filter the results in a subform(frmSubBikes). From the main form i have a button which opens another form(frmSell) which allows me to enter the sold price and when "cmdSell" is pressed many delete and append queries are run on the data stored in (frmSubBikes). When this button is pressd the deleted record has #deleted in each field where as it should be gone and i get this error message.
(The expression you entered refers to an object that is closed or does not exist)
What do i need to change? my minds been off this project for ages now ive got a brain block so help would be appreciated.

this is the code for "cmdSell"

If MsgBox("You are about to complte selling transaction: " & r & ". " & Chr(13) & " Is that correct ? ", vbQuestion + vbYesNo, " User Accounts") = vbYes Then

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70


DoCmd.SetWarnings False
DoCmd.OpenQuery "appSoldBikes", acNormal, acEdit
DoCmd.OpenQuery "UpdSoldBikes", acNormal, acEdit
DoCmd.OpenQuery "DelHires", acNormal, acEdit
DoCmd.OpenQuery "DelRepairs", acNormal, acEdit
DoCmd.OpenQuery "DelSoldBikes", acNormal, acEdit
DoCmd.Close
Me![frmSubBikes].Form.Filter = Searchstr
Me![frmSubBikes].Form.FilterOn = True
End If
Exit_cmdSave_Click:
Exit Sub

Hope you can help,
Thanks Sci
 
frmSell has the button on it, it is the form that pops up to enter the sold price
 
From the main form i have a button which opens another form(frmSell)
Use the acDialog argument of the OpenForm command on this button, if you don't already. Move this code:
Me![frmSubBikes].Form.Filter = Searchstr
Me![frmSubBikes].Form.FilterOn = True

from the "cmdSell" button on the form "frmSell" to after the OpenForm code under the command button on frmBikes. The first line of code after the OpenForm code should be:
Me!frmSubBikes.Form.Requery so when you are done the code lines are:

DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me!frmSubBikes.Form.Requery
Me!frmSubBikes.Form.Filter = Searchstr
Me!frmSubBikes.Form.FilterOn = True


...or at least something close to it.
 
Ok as far as i know that doesnt work heres the code for the button that opens up (frmSell)

Private Sub cmdSell_Click()
Dim SearchStr2 As String
SearchStr2 = "[BikeID] = " & Forms![frmBikes]![frmSubBikes].Form![BikeID]
DoCmd.OpenForm "frmSubSell", , , stLinkCriteria, , acDialog
Me!frmSubSell.Form.Filter = SearchStr2
Me!frmSubSell.Form.FilterOn = True
Me!frmSubBikes.Form.Requery
Me!frmSubBikes.Form.Filter = Searchstr
Me!frmSubBikes.Form.FilterOn = True
End Sub

I get runtime error 2450
that access can not find frmSubSell which means that frmSubSell wont display the record selected on frmBikes unless i use a different method to display the right record but at this stage it will be a bit of a cuffuffle.
 

Users who are viewing this thread

Back
Top Bottom