By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,671 Members | 1,278 Online
Bytes IT Community
+ 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

kcdoell
100+
P: 230
Hello:

I have the following afterupdate event:

Expand|Select|Wrap|Line Numbers
  1.  Private Sub GWP_AfterUpdate()
  2. 'Updates the Total calculation in the control "SumGWP" on the quick reference
  3. 'table that is located on the form
  4.  
  5.     With Me![SumGWP]
  6.     DoCmd.Requery
  7.  
  8.   End With
  9. 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
  1. 'Make sure required fields are filled out first
  2.  
  3. Dim frm As Form
  4. Set frm = Forms!Forecast
  5.  
  6. If IsNull(frm![Policy_Type]) Or IsNull(frm![Insured_Name]) _
  7. Or IsNull(frm![LOB]) Or Nz([GWP], 0) = 0 Or Nz([NWP], 0) = 0 _
  8. Or IsNull(frm![Binding_Percentage]) Then
  9.  
  10. If IsNull(frm![Policy_Type]) Then MsgBox "Please select a Policy Type from" & _
  11.     " the list, thank you", 64, "Select a Policy Type"
  12.  
  13. If IsNull(frm![Insured_Name]) Then MsgBox "Please indicate who the Insured" & _
  14.     " is, thank you", 64, "Select an Insured"
  15.  
  16. If IsNull(frm![LOB]) Then MsgBox "Please choose a LOB from the" & _
  17.     " list, thank you", 64, "Select an LOB"
  18.  
  19. If Nz([GWP], 0) = 0 Then MsgBox "Please input a GWP value for the" & _
  20.     " record, thank you", 64, "Input a GWP Value"
  21.  
  22. If Nz([NWP], 0) = 0 Then MsgBox "Please input a NWP value for the" & _
  23.     " record, thank you", 64, "Input a NWP Value"
  24.  
  25. If IsNull(frm![Binding_Percentage]) Then MsgBox "Please choose a Binding Percentage from" & _
  26.     " the list, thank you", 64, "Select a Binding Percentage"
  27.  
  28. Cancel = True
  29. Else: Cancel = False
  30. End If
  31.  
  32. '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
  1. runtime 2465 can't find field "|" referred to in your expression
The debug window focuses on the
Expand|Select|Wrap|Line Numbers
  1. With Me![SumGWP]
  2.     DoCmd.Requery 
  3.   End With
  4. 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
Share this Question
Share on Google+
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
  1. Private Sub GWP_AfterUpdate()
  2.   Me![SumGWP].Requery
  3. 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

kcdoell
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

kcdoell
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
  1.  =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

missinglinq
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
  1.  Private Sub GWP_AfterUpdate()
  2. With Me![SumGWP]
  3.   .Requery
  4. End With
  5. End Sub 
omitting the DoCmd.

Linq ;0)>
Apr 16 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.