Value isn't valid error

Rats

Registered User.
Local time
Today, 13:23
Joined
Jan 11, 2005
Messages
151
I have a sub form in a tabbed control that collects client income data. A subform of that [Tax table calc frm] calculates the tax payable and the following code displays the result in the [c1TaxMedi] and [c2taxmedi] fields on the income form.
Code:
Private Sub Command122_Click()
'Calculate taxation on income
[Tax Table Calc Frm].Form.Refresh
Me.C1TaxMedi = Form![Tax Table Calc Frm].Form![Text58]
Me.C2TaxMedi = Form![Tax Table Calc Frm].Form![Text70]
End Sub

The problem is that when I put data in the clients wages field then click the command button I get an error message "Run-Time error-2147352567(80020009) The value you entered isn't valid for this field.
When I go into debug the line
Code:
Me.C1TaxMedi = Form![Tax Table Calc Frm].Form![Text58]
is highlighted. If I don't do anything except close the debug window and return to the form the currency is display correctly in wages and if I press the command button again I get the tax to display without any errors.
I cannot fathom what is wrong with this code to get this effect.

Help appreciated Thanks.

Ooops realised I've posted in wrong category, don't know how to move it.M apologies.
 
Last edited:
The syntax looks wrong to me. I think it should be
Code:
Me.C1TaxMedi = Forms![Tax Table Calc Frm].[Text58]
 
Peter, add this diagnostic code:
Code:
Private Sub Command122_Click()
'Calculate taxation on income
[b]MsgBox "RecordCount = [" & _
Me.[Tax Table Calc Frm].Form.Recordset.RecordCount & "]" & _
vbCrLf & vbCrLf & _
"And the Plan ID is [" & Forms!customers.PlanID & "]"[/b]
[Tax Table Calc Frm].Form.Refresh
[b]MsgBox "RecordCount = [" & _
Me.[Tax Table Calc Frm].Form.Recordset.RecordCount & "]" & _
vbCrLf & vbCrLf & _
"And the Plan ID is [" & Forms!customers.PlanID & "]"[/b]
'Me.C1TaxMedi = Form![Tax Table Calc Frm].Form![Text58]
'Me.C2TaxMedi = Form![Tax Table Calc Frm].Form![Text70]
End Sub
I think you've lost the RecordSet again. I think you are getting back a Null which is a no-no.
 
Thanks

Thanks Neil and RG for your suggestions. I will see how they work.

Hey RG after all that work and apparent success I came in on Monday and blow me down, it was doing it again. (I am getting a good lesson in controlling frustration). Any way I got rid of the After Update code on each of the income controls and added a command button to calculate tax after the income was entered. This still generated the error on the same line. So I am wondering if the syntax Neil has suggested and I notice it in your code as well, is the answer. Soon know. I'll keep you posted.
 
no recordset

Hi RG.

Tried the syntax with no luck. Then tried the diagnostics and as you predicted I get 0 on the new ones. Is it problem with my Income query? Can't understand why it works at times and then doesn't.:(
 
Neil,
Peter can't use the Forms collection that way because he is executing from a SubForm. If anything he should replace Form with Me, but I think form works as well in this case.

Peter,
Did you get any return on the Plan ID? If not then that is why the [Tax Table Calc Frm] form is not returning any records. Something is clearing the Forms!customers.PlanID control.
 

Users who are viewing this thread

Back
Top Bottom