alliandrina
Registered User.
- Local time
- Today, 00:19
- Joined
- Mar 9, 2011
- Messages
- 13
I could use some help with VBA. To be honest, I don't know it and didn't write what I am about to post. I keep getting an error message that says 'invalid use of null"
Private Sub Form_BeforeUpdate(cancel As Integer)
Dim varW, varX, varY As Variant
If IsNull([CreateDate]) Then
varW = DLookup("[schoolID]", "tblteachers", "[name]= '" + cmbTeacher.Value + "'")
varX = DLookup("[ID]", "tblteachers", "[name]= '" + cmbTeacher.Value + "'")
[UserName] = CurrentUser()
[CreateDate] = Date + Time
[ModifyDate] = Date + Time
[SchoolID] = varW
[TeacherID] = varX
[Grade] = cmbGrade.Value
[SurveyDate] = txtFormDate.Value
[FormGroup] = CStr([TeacherID]) + [Grade] + CStr([SurveyDate])
[VisitDate] = txtVisitDate
[VisitTime] = txtVisitTime
[Duration] = txtDuration
txtSum.Requery
txtSumM.Requery
txtSumF.Requery
varY = DMax("[Rownumber]", "tblTeacherPresurvey", "[formgroup]= '" + [FormGroup] + "'")
[RowNumber] = IIf(IsNull(varY), 1, varY + 1)
Else
[ModifyDate] = Date + Time
End If
End Sub
The debugger highlights what's in marked in red. Is there something wrong with it? Do you need more information?
Private Sub Form_BeforeUpdate(cancel As Integer)
Dim varW, varX, varY As Variant
If IsNull([CreateDate]) Then
varW = DLookup("[schoolID]", "tblteachers", "[name]= '" + cmbTeacher.Value + "'")
varX = DLookup("[ID]", "tblteachers", "[name]= '" + cmbTeacher.Value + "'")
[UserName] = CurrentUser()
[CreateDate] = Date + Time
[ModifyDate] = Date + Time
[SchoolID] = varW
[TeacherID] = varX
[Grade] = cmbGrade.Value
[SurveyDate] = txtFormDate.Value
[FormGroup] = CStr([TeacherID]) + [Grade] + CStr([SurveyDate])
[VisitDate] = txtVisitDate
[VisitTime] = txtVisitTime
[Duration] = txtDuration
txtSum.Requery
txtSumM.Requery
txtSumF.Requery
varY = DMax("[Rownumber]", "tblTeacherPresurvey", "[formgroup]= '" + [FormGroup] + "'")
[RowNumber] = IIf(IsNull(varY), 1, varY + 1)
Else
[ModifyDate] = Date + Time
End If
End Sub
The debugger highlights what's in marked in red. Is there something wrong with it? Do you need more information?