Guest_imported
New member
- Jan 1, 1970
- 0
hello!
i have a student table and this is the vb code i put in the code builder behind the add record and close buttons. I have 2 problems.
1) It is not displaying the message i put in it. i.e if i try to put a duplicate record (it says "you cant go to the specified record".) i think it has to say "The student ID has to be unique.
2) Whenever i close the form and comeback, it won't refresh.
I have even got #delete before.
As, I am new to all this, Could anybody please try to figure out what's wrong with the code? Thanks a lot. The code is:
Private Sub Add_Click()
On Error GoTo Err_Add_Click
Dim i
DoCmd.GoToRecord , , acNewRec
Exit_Add_Click:
Exit Sub
Err_Add_Click:
If Err.Number = 3022 Then
i = MsgBox("The Student ID has to be unique", vbOKOnly, "Student Database "
Else
MsgBox Err.Description
Resume Exit_Add_Click
End If
End Sub
Private Sub Close_Click()
On Error GoTo Err_Close_Click
DoCmd.Close
Exit_Close_Click:
Exit Sub
Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click
End Sub
i have a student table and this is the vb code i put in the code builder behind the add record and close buttons. I have 2 problems.
1) It is not displaying the message i put in it. i.e if i try to put a duplicate record (it says "you cant go to the specified record".) i think it has to say "The student ID has to be unique.
2) Whenever i close the form and comeback, it won't refresh.
I have even got #delete before.
As, I am new to all this, Could anybody please try to figure out what's wrong with the code? Thanks a lot. The code is:
Private Sub Add_Click()
On Error GoTo Err_Add_Click
Dim i
DoCmd.GoToRecord , , acNewRec
Exit_Add_Click:
Exit Sub
Err_Add_Click:
If Err.Number = 3022 Then
i = MsgBox("The Student ID has to be unique", vbOKOnly, "Student Database "
Else
MsgBox Err.Description
Resume Exit_Add_Click
End If
End Sub
Private Sub Close_Click()
On Error GoTo Err_Close_Click
DoCmd.Close
Exit_Close_Click:
Exit Sub
Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click
End Sub