psycoperl
Active Member
- Joined
- Oct 23, 2007
- Messages
- 338
- Office Version
- 365
- 2016
- Platform
- Windows
- MacOS
- Web
I am trying to create a dialog box form (frmUpdateTestCode) that prompts the user to update some information to be processed.
When a user clicks on a button (cmdUpdateTestCode), I want to open the form and pass the other form the ID and Name to be displayed on the frmUpdateTestCode form.
I also want to have the Sub I have on the frmUpdateTestCode form (LoadStudentTestNeed) then run once the information is passed.
How can I do this?
on frmAppointmentScheduling I have :
on frmUpdateTestCode I have
When a user clicks on a button (cmdUpdateTestCode), I want to open the form and pass the other form the ID and Name to be displayed on the frmUpdateTestCode form.
I also want to have the Sub I have on the frmUpdateTestCode form (LoadStudentTestNeed) then run once the information is passed.
How can I do this?
on frmAppointmentScheduling I have :
Code:
Private Sub cmdUpdateTestCode_Click()
DoCmd.OpenForm "frmUpdateTestCode"
[Forms]![frmUpdateTestCode]!txtStuID.Value = Me.stuID
[Forms]![frmUpdateTestCode]!txtLastName.Value = Me.stuLastName
[Forms]![frmUpdateTestCode]!txtFirstName.Value = Me.stuFirstMiddleName
DoEvents
End Sub
on frmUpdateTestCode I have
Code:
Private Sub Form_Load()
LoadStudentTestNeed
End Sub
Sub LoadStudentTestNeed()
'Load Student Test Need
Dim strTestNeededCode As String
strTestNeededCode = ""
'If StudentID is present, check for the most recent test code.
'If there is a test code, display it on the screen
If (Not IsNull(Me.txtStuID)) And (Me.txtStuID <> vbNullString) _
And Len(Me.txtStuID) = 9 Then
'Verify Student ID
If VerifyStudentID(Me.txtStuID) Then
strTestNeededCode = GetTestNeedsCode(Me.txtStuID)
Dim strSQLTC As String 'String for Query
strSQLTC = "SELECT tblTestInfo.tiTestID, " & _
" tblTestInfo.tiEssay As E, " & _
" tblTestInfo.tiReading As D, " & _
" tblTestInfo.tiMath12 AS M12, " & _
" tblTestInfo.tiMath3 AS M3, " & _
" tblTestInfo.tiRetest AS RT " & _
"FROM tblTestInfo " & _
"WHERE (((tblTestInfo.tiTestID)='" & strTestNeededCode & "'))"
Dim rsTC As adodb.Recordset 'Record Set to hold TestCode Check Boxes
Set rsTC = New adodb.Recordset
rsTC.LockType = adLockReadOnly
rsTC.CursorType = adOpenStatic
rsTC.Open strSQLTC
If rsTC.RecordCount = 1 Then
'If there is a record - update check boxes
Me.chkReading = rsTC![D]
Me.chkEssay = rsTC![E]
Me.chkMath12 = rsTC![M12]
Me.chkMath3 = rsTC![M3]
Me.chkRetest = rsTC![RT]
Else
'If no record - set check boxes false
Me.chkReading = False
Me.chkEssay = False
Me.chkMath12 = False
Me.chkMath3 = False
Me.chkRetest = False
End If
rsTC.Close
Set rsTC = Nothing
End If
End If
End Sub