I'm building a database for my company, and I can't figure out why I'm getting these errors.
I'm transferring data from the subform (trailfrm) to the parent form (AD/Sieve Data), and doing math with the unbound fields to get a final value that gets stored. I need these fields on AD/Sieve Data cleared on current, and I've written code to do just that, but when I try to run code on trailfrm, it either says that it can't reference a property or method or a type mismatch. If I reference the textboxes as xxx.text, it says it can't reference the property or method for a control unless the control has the focus. If I have xxx.value, it has a type mismatch. I've tried setting the focus to AD/Sieve Data, but it doesn't help. I'm a novice programmer, so that's the extent of my knowledge of troubleshooting.
My code for trailfrm is:
Private Sub Command574_Click()
Dim rs As DAO.Recordset
Set rs = Me.Recordset
With rs
.MoveFirst
Do While Not .EOF
.Edit
If Me.Combo331.Value = "Lot" And Me.[Sample].Value = "1" And Me.Text575.Value = Forms![AD/Sieve Data]!Text1699.Value Then Forms![AD/Sieve Data]!Text1598.Value = Me.DC.Value
If Me.Combo331.Value = "Lot" And Me.[Sample].Value = "2" And Me.Text575.Value = Forms![AD/Sieve Data]!Text1699.Value Then Forms![AD/Sieve Data]!Text1600.Value = Me.DC.Value
If Me.Combo331.Value = "Lot" And Me.[Sample].Value = "3" And Me.Text575.Value = Forms![AD/Sieve Data]!Text1699.Value Then Forms![AD/Sieve Data]!Text1613.Value = Me.DC.Value
If IsNull(Forms![AD/Sieve Data]!Text1613.Value) Then Forms![AD/Sieve Data]!Text1602.Value = (Forms![AD/Sieve Data]!Text1598.Value + Forms![AD/Sieve Data]!Text1600.Value) / 2
*** [Debug points to this line] *** If Not IsNull(Forms![AD/Sieve Data]!Text1613.Value) Then Forms![AD/Sieve Data]!Text1602.Value = (Forms![AD/Sieve Data]!Text1598.Value + Forms![AD/Sieve Data]!Text1600.Value + Forms![AD/Sieve Data]!Text1613.Value) / 3
[Insert very similar, extensive math code here]
On Error Resume Next
.Update
.MoveNext
Loop
End With
Set rs = Nothing
End Sub
My code for AD/sieve data is:
Private Sub Form_Current()
Me.Text1578.Enabled = True
If Check1927.Value = False Then
Forms![AD/Sieve Data]!Trailfrm.Form!Text644.Visible = False
Forms![AD/Sieve Data]!Trailfrm.Form!Text646.Visible = False
Forms![AD/Sieve Data]!Trailfrm.Form!Text648.Visible = False
Forms![AD/Sieve Data]!Trailfrm.Form!Text650.Visible = False
Forms![AD/Sieve Data]!Trailfrm.Form!Text652.Visible = False
Forms![AD/Sieve Data]!Trailfrm.Form!Text704.Visible = False
Forms![AD/Sieve Data]!Trailfrm.Form!Text654.Visible = False
Forms![AD/Sieve Data]!Trailfrm.Form!Label703.Visible = False
Forms![AD/Sieve Data]!Text2013.Visible = False
Forms![AD/Sieve Data]!Text2015.Visible = False
Forms![AD/Sieve Data]!Text1950.Visible = False
Forms![AD/Sieve Data]!Text2023.Visible = False
Forms![AD/Sieve Data]!Text2025.Visible = False
Forms![AD/Sieve Data]!Text1974.Visible = False
Forms![AD/Sieve Data]!Label1951.Visible = False
Forms![AD/Sieve Data]!Label1975.Visible = False
Forms![AD/Sieve Data]!Label1836.Visible = False
Forms![AD/Sieve Data]!Text1835.Visible = False
End If
If Check1927.Value = True Then
Forms![AD/Sieve Data]!Trailfrm.Form!Text644.Visible = True
Forms![AD/Sieve Data]!Trailfrm.Form!Text646.Visible = True
Forms![AD/Sieve Data]!Trailfrm.Form!Text650.Visible = True
Forms![AD/Sieve Data]!Trailfrm.Form!Text648.Visible = True
Forms![AD/Sieve Data]!Trailfrm.Form!Text652.Visible = True
Forms![AD/Sieve Data]!Trailfrm.Form!Text704.Visible = True
Forms![AD/Sieve Data]!Trailfrm.Form!Text654.Visible = True
Forms![AD/Sieve Data]!Trailfrm.Form!Label703.Visible = True
Forms![AD/Sieve Data]!Text2013.Visible = True
Forms![AD/Sieve Data]!Text2015.Visible = True
Forms![AD/Sieve Data]!Text1950.Visible = True
Forms![AD/Sieve Data]!Text2023.Visible = True
Forms![AD/Sieve Data]!Text2025.Visible = True
Forms![AD/Sieve Data]!Text1974.Visible = True
Forms![AD/Sieve Data]!Label1951.Visible = True
Forms![AD/Sieve Data]!Label1975.Visible = True
Forms![AD/Sieve Data]!Label1836.Visible = True
Forms![AD/Sieve Data]!Text1835.Visible = True
End If
*** [This block of code causes the error] ***
Forms![AD/Sieve Data]!Text1598.Value = ""
Forms![AD/Sieve Data]!Text1600.Value = ""
Forms![AD/Sieve Data]!Text1613.Value = ""
Forms![AD/Sieve Data]!Text1175.Value = ""
Forms![AD/Sieve Data]!Text1179.Value = ""
Forms![AD/Sieve Data]!Text1183.Value = ""
Forms![AD/Sieve Data]!Text1250.Value = ""
Forms![AD/Sieve Data]!Text1248.Value = ""
Forms![AD/Sieve Data]!Text1187.Value = ""
Forms![AD/Sieve Data]!Text1378.Value = ""
Forms![AD/Sieve Data]!Text1380.Value = ""
Forms![AD/Sieve Data]!Text1382.Value = ""
Forms![AD/Sieve Data]!Text1387.Value = ""
Forms![AD/Sieve Data]!Text1389.Value = ""
Forms![AD/Sieve Data]!Text1391.Value = ""
Forms![AD/Sieve Data]!Text1523.Value = ""
Forms![AD/Sieve Data]!Text1525.Value = ""
Forms![AD/Sieve Data]!Text1526.Value = ""
Forms![AD/Sieve Data]!Text1929.Value = ""
Forms![AD/Sieve Data]!Text1931.Value = ""
Forms![AD/Sieve Data]!Text1933.Value = ""
Forms![AD/Sieve Data]!Text2013.Value = ""
Forms![AD/Sieve Data]!Text2015.Value = ""
Forms![AD/Sieve Data]!Text2023.Value = ""
Forms![AD/Sieve Data]!Text2025.Value = ""
End Sub
Screenshot: Here