A
Alan
Hi, fairly new to this and hope I can get some help. I keep getting "Run-time
error '2448' You can't assign a value to this object" each time the code in
my form runs.
I have a query based on a couple of tables and in turn a form based on this
query. A default value of 16 is assigned to [Sample Size] in a table; on
Form_Open I want the code to run, check the Lot Number value with a range I
specify, then if the value of [Sample Size] is 16 change it to 15 and save
this value back to my table.
If I open the form without code active I can overtype [Sample Size] with any
value I want and this is saved back to my table but I don't want users to do
this so why can't I do it through code? Is my reference to [Sample Size] in
code not correct? Does it need to be Tables!MyTable.[Sample Size] or
something like that because I can't find the syntax that works.
TIA
Private Sub Form_Open(Cancel As Integer)
CheckSampleSize
End Sub
Function CheckSampleSize()
If [Lot Number] >= 300000 And [Lot Number] <= 399999 Then
Select Case [Sample Size]
Case Is = 16
[Sample Size] = 15
End Select
End If
End Function
error '2448' You can't assign a value to this object" each time the code in
my form runs.
I have a query based on a couple of tables and in turn a form based on this
query. A default value of 16 is assigned to [Sample Size] in a table; on
Form_Open I want the code to run, check the Lot Number value with a range I
specify, then if the value of [Sample Size] is 16 change it to 15 and save
this value back to my table.
If I open the form without code active I can overtype [Sample Size] with any
value I want and this is saved back to my table but I don't want users to do
this so why can't I do it through code? Is my reference to [Sample Size] in
code not correct? Does it need to be Tables!MyTable.[Sample Size] or
something like that because I can't find the syntax that works.
TIA
Private Sub Form_Open(Cancel As Integer)
CheckSampleSize
End Sub
Function CheckSampleSize()
If [Lot Number] >= 300000 And [Lot Number] <= 399999 Then
Select Case [Sample Size]
Case Is = 16
[Sample Size] = 15
End Select
End If
End Function