Dirk said:
It sounds like you already had an event procedure for the form's
BeforeInsert event. I assumed that you wouldn't, because you said you
are unfamiliar with VBA code. Are you modifying a form that somebody
else created?
If you'd like to copy and paste the complete form module code, we may be
able to tell you what to do to fix the problem.
Good morning,
I created my database myself, and didn't understand things like dlookup,
so O asked around and had some great help from memebers of the
newsgroup. Just now I am trying to make the database more "handyer" so
that's why I would like to limit the records that can be added. Here's
the code
Option Compare Database
Private Sub Form_AfterInsert()
End Sub
Private Sub Form_AfterUpdate()
End Sub
Private Sub Form_BeforeInsert(Cancel As Integer)
Me.StudentId = Forms.student.StudentId
End Sub
Private Sub Form_Current()
Me.KeuzeLand = DLookup("HotelLand", "Hotels", "HotelId = " & Me.Hotelid)
Me.Hotelid.RowSource = "SELECT HotelId, Hotelnaam FROM Hotels WHERE
HotelLand = '" & _
Me.KeuzeLand & "' ORDER BY Hotelnaam"
Me.Hotelid.Requery
End Sub
Private Sub KeuzeLand_AfterUpdate()
Me.Hotelid.RowSource = "SELECT HotelId, Hotelnaam FROM Hotels WHERE
HotelLand = '" & _
Me.KeuzeLand & "' ORDER BY Hotelnaam"
End Sub
Private Sub Record_toevoegen_Exit(Cancel As Integer)
End Sub
Private Sub Vorige_record_Click()
On Error GoTo Err_Vorige_record_Click
DoCmd.GoToRecord , , acPrevious
Exit_Vorige_record_Click:
Exit Sub
Err_Vorige_record_Click:
MsgBox Err.Description
Resume Exit_Vorige_record_Click
End Sub
Private Sub Volgende_record_Click()
On Error GoTo Err_Volgende_record_Click
DoCmd.GoToRecord , , acNext
Exit_Volgende_record_Click:
Exit Sub
Err_Volgende_record_Click:
MsgBox Err.Description
Resume Exit_Volgende_record_Click
End Sub
Private Sub Record_toevoegen_Click()
On Error GoTo Err_Record_toevoegen_Click
DoCmd.GoToRecord , , acNewRec
Exit_Record_toevoegen_Click:
Exit Sub
Err_Record_toevoegen_Click:
MsgBox Err.Description
Resume Exit_Record_toevoegen_Click
End Sub