Prob with Update Code

Surdeymon

Registered User.
Local time
Yesterday, 22:18
Joined
Jun 10, 2004
Messages
11
Hello - I have a subform set up in datasheet view and I want the following to occur: When a user enters a date in one field - I want code to calculate the difference in months between that date and another date, find the value of nbr based on that difference and assign that value to another control in the same record in that subform. Since I cannot assign a value to a control in subform in datasheet view - I set up the following code to update the recordset (table) itself. GradeID is the Primary key in that table

The problem is that I get an error b/c User defined type not defined - the explanation I get in the help text does not make sense to me - Any ideas what may be wrong with this code - Thx in advance -

-------------------------------------------

Private Sub txtvisitdate_AfterUpdate()

Dim Nbr As Integer
Dim dd As Integer
Dim dbs As Database
Dim rst As Recordset

Set dbs = OpenDatabase("BreastAugmentation")
Set rst = dbs.Openrecordset("tblBreastAssessments")

dd = DateDiff("m", [Forms]![frmBreastAssessmentDataForm]![DOS], Me.txtvisitdate)

Select Case dd
Case Is <= 1
Nbr = 1
Case 2 To 3
Nbr = 2
Case 4 To 6
Nbr = 3
Case 7 To 9
Nbr = 4
Case 10 To 12
Nbr = 5
Case 13 To 24
Nbr = 6
Case 25 To 37
Nbr = 7
Case 38 To 49
Nbr = 8
Case 50 To 61
Nbr = 9
Case 62 To 73
Nbr = 10
Case 74 To 85
Nbr = 11
Case 86 To 97
Nbr = 12
Case 98 To 109
Nbr = 13
Case Is >= 110
Nbr = 14
End Select

With rst
Set postopID = Nbr
WHERE GradeID = Me.GradeID
End With

Me.Requery

End Sub
 
What version of access? You probably need to add a reference to DAO.

Search the boards for MISSING REFERENCE DAO - I am sure 100000 post will pop up..
 
That did it - Thx for your help!

That did it - Thx for your help!
 

Users who are viewing this thread

Back
Top Bottom