Hi Van,
I do have a CommandButton named "openfrmThuha" and in the "On Click" row of
the Event tab of the Properties window of the CommandButton, I have entered
the following:
Private Sub frmThuha_Click()
If DCount("*", "tblThuha", "[AUID]=" & Me.AUID) > 0 Then
'StudentID exists
DoCmd.OpenForm "frmThuha", , , "[AUID]=" & Me.AUID
Else
'StudentID doesn't exist
MsgBox "Student ID doesn't exist. Please re-enter Student ID."
End If
End Sub
AUID is not a text field, but an autonumber, so I slightly changed the code
a bit. The form is somewhat half done. Thanks for being patient with me and
hopefully you can guide me to correct my problems.
When I open the frmPreProcess, the AUID field automatically has a record in
it...i.e. 123. Is there way to make the form opens with nothing inside the
AUID field? As of right now, if I click the submit button, it'll bring up
student's record 123 which is correct. If I replaced 123 with 689 and clicked
the submit button, it'll display "Student ID doesn't exist. Please re-enter
Student ID" and there's an OK button. That's perfect. The problem NOW is when
I close the frmPreProcess and re-open it, the number 689 appears in the AUID
field and when I click the Submit button, the form appears with 689 in the
AUID field. It should give me the message box that the student ID doesn't
match, please enter the student ID again. What am I doing wrong? If there's
a way for me to send you the db, please let me know.
Thank you for being patience with me.
Van T. Dinh said:
Sorry, I am not sure what you did???
Do you have a CommandButton named "openfrmThuha" on the current Form?
If you do, what did you enter in the "On Click" row in the Event tab of the
Properties window of the CommandButton?
If you don't know how to use Events and to create Event Procedure codes,
suggest you check Access Help on preferably, read up on an Access
programming book.
--
HTH
Van T. Dinh
MVP (Access)
Bagia said:
Hi Van,
I tried to enter the argument in the Event Procedure and received an error
message "Compile error: Method or data member not found". Below is my Even
Procedure. Can you tell me what I'm doing wrong here? Thank you for help.
Private Sub openfrmThuha_Click()
If DCount("*", "tblThuha", "[AUID] = " & Me.txtAUID) > 0 Then
'AUID exists
DoCmd.OpenForm "frmThuha", , , "[AUID]=" & Me.txtAUID
Else
'StudentID doesn't exist
MsgBox "AU ID incorrect. Please re-enter AU ID."
End If
On Error GoTo Err_openfrmThuha_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmThuha"
stLinkCriteria = "[AU ID]=" & Me![Combo4]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_openfrmThuha_Click:
Exit Sub
Err_openfrmThuha_Click:
MsgBox Err.Description
Resume Exit_openfrmThuha_Click
End Sub