Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to assign values to text boxes.

Status
Not open for further replies.

ROhri

IS-IT--Management
Nov 24, 2000
3
US
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
 
Figured out my own question... Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top