L.S.
I'm trying to enable a specific field in a datasheet subform, but all the
records in the subform get the same data.
I'm using this coding to update the fields in the subform.
Thanks in advance for your help.
Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Dim dbs As DAO.Database
Dim varX As Variant
Set dbs = CurrentDb
Set rst = Nothing
Set rst1 = Nothing
Set subform = Forms!Frminstruments!FrmSubinstrument.Form
Set Mainform = Forms!Frminstruments
SQL = "Select [Calibration Cycle]" & _
" FROM TblIDseq Where IDprocess = '" & Mainform!IDnr & "' AND
IDintstru = '" & Mainform!IDinstr & "'"
Set rst1 = dbs.OpenRecordset(SQL)
If rst1.EOF Then
MsgBox ("Error:.. Identification Number not valid")
Me.IDnr.SetFocus
Set rst1 = Nothing
Set dbs = Nothing
Exit Sub
End If
If subform![Calib Type].Value = "No apply" Then
subform!Calcycle.Enabled = False
subform!Department.Enabled = False
subform![Calibration expr].Enabled = False
Exit Sub
End If
Me!Calcycle.Enabled = True
Me!Department.Enabled = True
Me![Calibration expr].Enabled = True
Me!Calcycle = rst1("Calibration Cycle")
If Me!Calcycle = "1 year" Then
Me![Calibration expr] = DateAdd("yyyy", 1, [Last Calibration])
End If
If Me!Calcycle = "2 years" Then
Me![Calibration expr] = DateAdd("yyyy", 2, [Last Calibration])
End If
If Me!Calcycle = "3 years" Then
Me![Calibration expr] = DateAdd("yyyy", 3, [Last Calibration])
End If
If Me!Calcycle = "5 years" Then
Me![Calibration expr] = DateAdd("yyyy", 5, [Last Calibration])
End If
If Me!Calcycle = "6 months" Then
Me![Calibration expr] = DateAdd("m", 6, [Last Calibration])
End If
If Me!Calcycle = "9 months" Then
Me![Calibration expr] = DateAdd("m", 9, [Last Calibration])
End If
rst1.Close
Set rst1 = Nothing
Set rst = Nothing
Set db = Nothing
--
Message posted via
http://www.accessmonster.com