I am a new user to access/vBA. I have a script that prompts the user to enter a Student ID. The Student ID that is entered is compared with all the students in the database and outputs in the form of a message box. The problem is that I want to output these fields... (i.e. Student_Last_Name, Student_First_Name, Address) in separate text boxes. I have created a new form with unbound text boxes and now I don't know how to adjust the code to ouput to the unbound text boxes... I would appreciate any help on this. Thanks! I have pasted the code below:
Function Command0_Click()
'On Error GoTo Err_Command0_Click
Dim retval As Variant
retval = InputBox("Enter student ID", "Student ID", ""
Dim db As Database, rst As Recordset, SQL As String
Set db = CurrentDb
' SQL string.
SQL = "SELECT * FROM Student WHERE Student_ID = '" & retval & "';"
Set Student = db.OpenRecordset(SQL)
If Student.RecordCount > 0 Then
MsgBox "Found Student " & Student!Student_ID & " - " & " " & Student!S_L_Name & " " & Student!S_F_Name, vbInformation, "Found Student"
Else
MsgBox "Student ID " & retval & " Not found!!!", vbExclamation, "Missing student ID"
End If
Student.Close
db.Close
Exit_Command0_Click:
Exit Function
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Function
Function Command0_Click()
'On Error GoTo Err_Command0_Click
Dim retval As Variant
retval = InputBox("Enter student ID", "Student ID", ""
Dim db As Database, rst As Recordset, SQL As String
Set db = CurrentDb
' SQL string.
SQL = "SELECT * FROM Student WHERE Student_ID = '" & retval & "';"
Set Student = db.OpenRecordset(SQL)
If Student.RecordCount > 0 Then
MsgBox "Found Student " & Student!Student_ID & " - " & " " & Student!S_L_Name & " " & Student!S_F_Name, vbInformation, "Found Student"
Else
MsgBox "Student ID " & retval & " Not found!!!", vbExclamation, "Missing student ID"
End If
Student.Close
db.Close
Exit_Command0_Click:
Exit Function
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Function