424,671 Members | 1,278 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,671 IT Pros & Developers. It's quick & easy.

# AfterUpdate Event - runtime 2465 can't find field "|" referred to in your expression

 100+ P: 230 Hello: I have the following afterupdate event: Expand|Select|Wrap|Line Numbers  Private Sub GWP_AfterUpdate() 'Updates the Total calculation in the control "SumGWP" on the quick reference 'table that is located on the form       With Me![SumGWP]     DoCmd.Requery     End With End Sub  This worked perfectly. Then I applied code to various objects so that a new record could not be written unless certain conditions existed. In the case of my object "GWP", the value has to greater than 0: Expand|Select|Wrap|Line Numbers 'Make sure required fields are filled out first   Dim frm As Form Set frm = Forms!Forecast   If IsNull(frm![Policy_Type]) Or IsNull(frm![Insured_Name]) _ Or IsNull(frm![LOB]) Or Nz([GWP], 0) = 0 Or Nz([NWP], 0) = 0 _ Or IsNull(frm![Binding_Percentage]) Then   If IsNull(frm![Policy_Type]) Then MsgBox "Please select a Policy Type from" & _     " the list, thank you", 64, "Select a Policy Type"   If IsNull(frm![Insured_Name]) Then MsgBox "Please indicate who the Insured" & _     " is, thank you", 64, "Select an Insured"   If IsNull(frm![LOB]) Then MsgBox "Please choose a LOB from the" & _     " list, thank you", 64, "Select an LOB"   If Nz([GWP], 0) = 0 Then MsgBox "Please input a GWP value for the" & _     " record, thank you", 64, "Input a GWP Value"   If Nz([NWP], 0) = 0 Then MsgBox "Please input a NWP value for the" & _     " record, thank you", 64, "Input a NWP Value"   If IsNull(frm![Binding_Percentage]) Then MsgBox "Please choose a Binding Percentage from" & _     " the list, thank you", 64, "Select a Binding Percentage"   Cancel = True Else: Cancel = False End If   'If all req fields are populated then proceed to write the record to the forecast table. My problem is that if GWP is 0, I get the error message. That is what I wanted to happen but when I input a value greater than 0 and tab into my next object "NWP", I get the following error" Expand|Select|Wrap|Line Numbers runtime 2465 can't find field "|" referred to in your expression The debug window focuses on the Expand|Select|Wrap|Line Numbers With Me![SumGWP]     DoCmd.Requery    End With End Sub  Highlighting the DoCmd.Requery…. I have been doing a lot of research on the Internet but can not find a solution. Does anybody understand what my issue could be? During my research it indicated that this message could mean that it can not find the object, but that was not an issue before I put in the required field error messages. Any ideas would be helpful. Thanks, Keith. Apr 15 '08 #1
4 Replies

 Expert Mod 2.5K+ P: 2,545 Hi Keith. Can't see any obvious cause for the error in the code as posted. Having said that you are mixing the syntax for the requery a little - you don't need the With or the DoCmd. The syntax is just Expand|Select|Wrap|Line Numbers Private Sub GWP_AfterUpdate()   Me![SumGWP].Requery End Sub  The other checking lines don't explain why you should be getting an error. If you find you are still getting the error after simplifying the requery line as above, could you post the calculation you use for your SumGWP field that is being requeried? It may be that there is something wrong there instead. -Stewart Apr 15 '08 #2

 100+ P: 230 Hi Keith. Can't see any obvious cause for the error in the code as posted. Having said that you are mixing the syntax for the requery a little - you don't need the With or the DoCmd.................. Stewart: I just got back and thanks for the reply. I am going to probe a little further trying your suggestion and get back to you........ Apr 15 '08 #3

 100+ P: 230 Stewart: Simplifying the requery coding as you suggested seems to have worked. I now can not recreate the error. This was the first time I wrote that kind of code and it did work before I proceed with other VB coding. I am always interested in streamlining how I write stuff but I have learned all by doing and none by formal training. Thanks, I would not have figured it out without your help. For kicks my code for the SUMGWP was the following: Expand|Select|Wrap|Line Numbers  =DSum("[GWP]","ReQryForecast","Val([Binding_Percentage]) >= 75")  This I placed in the control source property of my text box control…. Thanks again, Keith. Apr 15 '08 #4

 Expert 2.5K+ P: 3,532 For doing this one simple thing, using the With construct was really overkill, and Stewart's suggestion was spot on, as always. But if you needed to use the With because you were also doing other things, the proper syntax would have been Expand|Select|Wrap|Line Numbers  Private Sub GWP_AfterUpdate() With Me![SumGWP]   .Requery End With End Sub  omitting the DoCmd. Linq ;0)> Apr 16 '08 #5