Hi
I have a calendar table which has a date field, 'TeachDay' and a weekday field 'Weekday'.
I wish to write VBA code to add records for each new day and then to store the weekday (okay perhaps it should be calculated on the fly but I want to do this vba code).
I have succeeded in adding new days with the code below but only get a type mismatch with the weekday function part. What am I missing here?
Private Sub Command17_Click()
Dim TempDate As Date
Dim TempWeekday As Integer
'Adds new record to tblTeachDay
DoCmd.GoToRecord , , acNewRec
'Looks up highest existing date and adds one to it
TempDate = (DMax("[TeachDayDate]", "[tblTeachDay]")) + 1
'Makes the new date field in the table = to the calculated date
TeachDayDate = TempDate
'Finds the day of the week for the new date
TempWeekday = Weekday(TempDate) xxxxtype mismatch errorxxx
'Puts the date integer on the form for inspection
Me!txtTemp = TempWeekday
DoCmd.Beep
End Sub
I have a calendar table which has a date field, 'TeachDay' and a weekday field 'Weekday'.
I wish to write VBA code to add records for each new day and then to store the weekday (okay perhaps it should be calculated on the fly but I want to do this vba code).
I have succeeded in adding new days with the code below but only get a type mismatch with the weekday function part. What am I missing here?
Private Sub Command17_Click()
Dim TempDate As Date
Dim TempWeekday As Integer
'Adds new record to tblTeachDay
DoCmd.GoToRecord , , acNewRec
'Looks up highest existing date and adds one to it
TempDate = (DMax("[TeachDayDate]", "[tblTeachDay]")) + 1
'Makes the new date field in the table = to the calculated date
TeachDayDate = TempDate
'Finds the day of the week for the new date
TempWeekday = Weekday(TempDate) xxxxtype mismatch errorxxx
'Puts the date integer on the form for inspection
Me!txtTemp = TempWeekday
DoCmd.Beep
End Sub