Hello:
I have the following afterupdate event:
[code=vb] 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 [/code]
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:
[code=vb]'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_Percent age]) 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_Percent age]) 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.[/code]
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"
[code=text]runtime 2465 can't find field "|" referred to in your expression[/code]
The debug window focuses on the
[code=vb]With Me![SumGWP]
DoCmd.Requery
End With
End Sub [/code]
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.
I have the following afterupdate event:
[code=vb] 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 [/code]
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:
[code=vb]'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_Percent age]) 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_Percent age]) 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.[/code]
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"
[code=text]runtime 2465 can't find field "|" referred to in your expression[/code]
The debug window focuses on the
[code=vb]With Me![SumGWP]
DoCmd.Requery
End With
End Sub [/code]
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.
Comment