mmmmm I'm not sure about the code. but here is the code for the form what i have. I haven't touched anything though.. am I meant to? I just added a combo box and linked to the "Campus" query..
Thank you for a prompt reply!
Option Compare Database
Option Explicit
Private Sub cmdplacementtest_Click()
On Error GoTo Err_cmdplacementtest_Click
Dim lngStudentID
' Get the ID of the record that was clicked.
lngStudentID = Me.Controls("student_id")
' Open the form passing the UID of the record to display.
DoCmd.OpenForm "Placement Test", , , "student_id = " & lngStudentID, acFormEdit, , lngStudentID
Exit_cmdplacementtest_Click:
Exit Sub
Err_cmdplacementtest_Click:
MsgBox Err.Description
Resume Exit_cmdplacementtest_Click
End Sub
Private Sub Form_AfterInsert()
' Enable links to child functions.
Me.cmdAlumni.Enabled = True
Me.cmdHomestayRecord.Enabled = True
Me.cmdIELTSResults.Enabled = True
Me.cmdAddEnrolment.Enabled = True
End Sub
Private Sub Form_Dirty(Cancel As Integer)
Me.cmdSave.Enabled = True
End Sub
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_cmdSave_Click:
Exit Sub
Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click
End Sub
Private Sub Form_Load()
On Error GoTo Err_Form_Load
Dim lngStudentID As Long
If (IsNull(Me.OpenArgs)) Then
lngStudentID = 0
ElseIf (Me.OpenArgs = "") Then
lngStudentID = 0
Else
lngStudentID = CLng(Me.OpenArgs)
End If
If (lngStudentID = 0) Then
' Adding a new record.
DoCmd.GoToRecord , , acNewRec
Me.first_name.SetFocus
' Diasble links to child functions. Enable in the AfterInsert handler.
Me.cmdAlumni.Enabled = False
Me.cmdHomestayRecord.Enabled = True
Me.cmdIELTSResults.Enabled = False
Else
' Editing an existing record.
Me.prospect_id.Enabled = False
End If
Exit_Form_Load:
Exit Sub
Err_Form_Load:
MsgBox Err.Description
Resume Exit_Form_Load
End Sub
Private Sub Form_Open(Cancel As Integer)
If ((IsNull(Me.OpenArgs)) Or (Me.OpenArgs = "")) Then
MsgBox "A student has not been selected for maintenance.", vbCritical Or vbOKOnly, "Error"
Cancel = True
End If
End Sub
Private Sub prospect_id_Click()
Dim rs As Object
Dim sSQL As String
CurrentDb.Execute ("INSERT INTO Prospect (temp) VALUES ('a');")
sSQL = "select max(prospect_id) as pid from Prospect;"
Set rs = CurrentDb.OpenRecordset(sSQL)
student_id = rs("pid")
Me.first_name.SetFocus
Me.prospect_id.Enabled = False
End Sub
Private Sub cmdHomestayRecord_Click()
On Error GoTo Err_cmdHomestayRecord_Click
Dim lngStudentID
' Get the ID of the record that was clicked.
lngStudentID = Me.Controls("student_id")
' Open the form passing the UID of the record to display.
DoCmd.OpenForm "Homestay Record", , , "student_id = " & lngStudentID, acFormEdit, , lngStudentID
Exit_cmdHomestayRecord_Click:
Exit Sub
Err_cmdHomestayRecord_Click:
MsgBox Err.Description
Resume Exit_cmdHomestayRecord_Click
End Sub
Private Sub cmdIELTSResults_Click()
On Error GoTo Err_cmdIELTSResults_Click
Dim lngStudentID
' Get the ID of the record that was clicked.
lngStudentID = Me.Controls("student_id")
' Open the form passing the UID of the record to display.
DoCmd.OpenForm "IELTS", , , "student_id = " & lngStudentID, acFormEdit, , lngStudentID
Exit_cmdIELTSResults_Click:
Exit Sub
Err_cmdIELTSResults_Click:
MsgBox Err.Description
Resume Exit_cmdIELTSResults_Click
End Sub
Private Sub cmdAlumni_Click()
On Error GoTo Err_cmdAlumni_Click
Dim lngStudentID
' Get the ID of the record that was clicked.
lngStudentID = Me.Controls("student_id")
' Open the form passing the UID of the record to display.
DoCmd.OpenForm "Alumni", , , "student_id = " & lngStudentID, acFormEdit, , lngStudentID
Exit_cmdAlumni_Click:
Exit Sub
Err_cmdAlumni_Click:
MsgBox Err.Description
Resume Exit_cmdAlumni_Click
End Sub
Private Sub cmdClasses_Click()
On Error GoTo Err_cmdClasses_Click
Dim lngStudentID
' Get the ID of the record that was clicked.
lngStudentID = Me.Controls("student_id")
' Open the form passing the UID of the record to display.
DoCmd.OpenForm "Classes", , , "student_id = " & lngStudentID, acFormEdit, , lngStudentID
Exit_cmdClasses_Click:
Exit Sub
Err_cmdClasses_Click:
MsgBox Err.Description
Resume Exit_cmdClasses_Click
End Sub
Private Sub cmdStatus_Click()
On Error GoTo Err_cmdStatus_Click
Dim lngStudentID
' Get the ID of the record that was clicked.
lngStudentID = Me.Controls("student_id")
' Open the form passing the UID of the record to display.
DoCmd.OpenForm "Status", , , "student_id = " & lngStudentID, acFormEdit, , lngStudentID
Exit_cmdStatus_Click:
Exit Sub
Err_cmdStatus_Click:
MsgBox Err.Description
Resume Exit_cmdStatus_Click
End Sub
Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click
DoCmd.Close
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click
End Sub