AfterUpdate() event error

Data-Logger

New member
Local time
Today, 01:08
Joined
May 10, 2012
Messages
2
Hi Guys,

I have an issue with an application I have in relation to the AfterUpdate() event.

Private Sub Form_AfterUpdate()
Forms!frmOrderPlacement!frmOrderItems.Form!cboProducts.Requery
Forms!frmAccountCustomersPrices!subfrmPrices!Combo0.Requery
End Sub

In my application as a accdb, this works fine, however, when I convert it to an accdr to distribute to my users it keeps throwing an that the forms cannot be located.

The forms in the AfterUpdate() are not always open, this is subject to how this particular form has been opened.

Anyone any suggestions?
 
The forms must be open to be included in the Forms Collection regardless whether the database is an executable or source.

Use the IsLoaded property of the form in the AllForms Collection to determine if the form is open.

CurrentProject.AllForms.formname.IsLoaded
 
Hey Guys,

Thanks for that, can I confirm that what you are suggesting is I change the afterupdate() to :

Private Sub Form_AfterUpdate()
project.AllForms.frmOrderPlacement!frmOrderItems.IsLoaded
Forms!frmOrderPlacement!frmOrderItems.Form!cboProducts.Requery
project.AllForms.frmAccountCustomersPrices!subfrmPrices.IsLoaded
Forms!frmAccountCustomersPrices!subfrmPrices!Combo0.Requery
End Sub

Many thanks
 
if the form may or may not be open, and you do not care you could just do

Private Sub Form_AfterUpdate()
onerror resume next
Forms!frmOrderPlacement!frmOrderItems.Form!cboProd ucts.Requery
onerror resume next
Forms!frmAccountCustomersPrices!subfrmPrices!Combo 0.Requery
End Sub

however, why would this not give you an error in an accde, but not in the accdb?
 
Forms!frmAccountCustomersPrices!subfrmPrices!Combo 0.Requery

Is this a Typo or do you have a space after Combo?

Anyway Combo is not very descriptive. You should rename.
 
Is this a Typo or do you have a space after Combo?

The space is inserted by the board to give the html renderer an opportunity to wrap the line before it exceeds the page width.

It is one of several reasons why code should be posted in a code box.
 
The space is inserted by the board to give the html renderer an opportunity to wrap the line before it exceeds the page width.

It is one of several reasons why code should be posted in a code box.

Thanks for that.
 
Private Sub Form_AfterUpdate()
onerror resume next
Forms!frmOrderPlacement!frmOrderItems.Form!cboProd ucts.Requery
onerror resume next
Forms!frmAccountCustomersPrices!subfrmPrices!Combo 0.Requery
End Sub

A couple of points.

On Error should be two separate words.

Once declared the Error regime sticks until changed. There is no need to repeat the declaration before each line unless you want the current error code to be cleared before the next error is raised for some reason.

More importantly the error handling would need to be changed back to the desired system after the lines or all subsequent errors will be ignored. If the procedure does not use a handler the line would be:
On Error GoTo 0

Personally I consider On Error Resume Next is a last resort when there is no other logic that can be implimented to avoid an error. However I acknowledge that is just my preference and there is nothing intrinsically wrong with the Resume Next.

The only time I can remember ever using it was to edit the LinkMasterFields Property of a subformcontrol. I needed to add another field and that temporarily mismatched the number of LinkChildFields until that was similarly changed.
 

Users who are viewing this thread

Back
Top Bottom