Howlsta
Vampire Slayer
- Local time
- Today, 11:31
- Joined
- Jul 18, 2001
- Messages
- 180
If I select the command button i get an error
in the code on line 2 (db As Database). Why is this? I based this on a similar example in a book, so thought it would be ok, it's probably simple. Can anyone help?
Private Sub cmdAdd_click()
Dim db As Database
Dim rstCourseModYr As Recordset
If IsNull(Me.CboModule) Or _
IsNull(Me.CboYr) Then
MsgBox "The module and year of course must be selected"
Else
Set db = CurrentDb()
Set rstCourseModYr = db.OpenRecordset("qryCourseModuleYr", _
dbOpenDynaset)
With rstCourseModYr
.AddNew
!CourseID = Me!CourseID
!NumberYr = Me!CboYr
!ModuleCode = Me!CboModule
.Update
.Bookmark = rstCourseModYr.lastModified
End With
Me!CourseIDF = rstCourseModYr!CourseIDF
in the code on line 2 (db As Database). Why is this? I based this on a similar example in a book, so thought it would be ok, it's probably simple. Can anyone help?
Private Sub cmdAdd_click()
Dim db As Database
Dim rstCourseModYr As Recordset
If IsNull(Me.CboModule) Or _
IsNull(Me.CboYr) Then
MsgBox "The module and year of course must be selected"
Else
Set db = CurrentDb()
Set rstCourseModYr = db.OpenRecordset("qryCourseModuleYr", _
dbOpenDynaset)
With rstCourseModYr
.AddNew
!CourseID = Me!CourseID
!NumberYr = Me!CboYr
!ModuleCode = Me!CboModule
.Update
.Bookmark = rstCourseModYr.lastModified
End With
Me!CourseIDF = rstCourseModYr!CourseIDF