Forms

clauses

Registered User.
Local time
Today, 11:25
Joined
Feb 9, 2001
Messages
56
I built a form used to display student grades. The main form displays student informatin such as address and a subform is used to display the student grades. The main fomr and subform are linked together using the student Id. How can I set up the main form so when I change the student Id it displays the new students information but does not update andy records.
 
You don't tell me enough to be sure, so I'll tell you what I would do.

First things first, set the data properties on the subform so that the form is locked.

Then, if YOU wanted to use the subform to enter data, make a copy of the subform and a copy of the parent. Secure the parent form so only you can use it, then unlock the data fields of the subform on your copy. Leave the public copy with its subform locked.

That's what I would do.
 
The upper portion of my main form contains student information such as student Id, name, address, etc. Within the main form is a subform which list the classes the student has taken and the grade they received. I would like to enter a Students ID into the ID field and have that students records displayed by the form. At the present time I receive a messge about a relationship prohibiting one of my files from being updated. I used a query to build the student information from several different files and l also locked all the fields except for the Student Id.
 
My thought is that you are using the control StudentID as your "choice". That will not work as it will create duplicate values in your table and you will get the error you described.

Use the toolbox to place a combo box on the form. Use the table that has the studentID main form data as a source. Choose option #3, Find records based on my selection.

I think that is what you are wanting to do.
 
Yes I do want to use the student id as my choice and I do receive the error. When I removed the text box used for student Id and replaced it with a combo box I was not able to select any options. The information utilized in the student section of my form uses a query to obtains all the desired information instead of a table, if that makes a difference.
 
I am assuming that you have a 1-1 relationship between your student info and grades tables. If you have a lot of students, you may find a dropdown too big but it does remove typing errors and you can set it to auto complete. I use an unbound text box to enter the Id/Code I want to display then base the main form a query with (in your case) the StudentId criteria set to
[Forms]![MainForm]![NameOfUnboundTextBox]
On the AfterUpdate property of the 'search box' code it to

Sub SearchBox_AfterUpdate()
Me.Requery
End Sub

It will then display the record of your choice. You can do the same with an unbound combobox
[Forms]![MainForm]![NameOfComboBox].

If you use a combobox, on the rowsource property, click on the buildicon and set up your query to populate the box. You will need at least the StudentID. Set the number of columns to the number of fields you have chosen and the column widths to whatever you want other than 0 as this will hide the column.

HTH

edit corrected typos

[This message has been edited by Fizzio (edited 11-20-2001).]
 
This technique still gives me an error becuase a relationship exist between two of the tables used in my query. The error states that my student Id cannot be changed or deleted due to its relationship with another table. The relationship exist in order to prevent the user from placing a student that does not exist in a class. Other than changing the relationship I am not sure how to keep this error from occuring.
 
You need to have a relationship with the tables.
I assume you have tables as shown.

StudentInfo
-----------
StudentID AutoNumber (Key)
etc

StudentGrades
-------------
StudentID LongInteger (Key)
etc

This forms your 1-1 relationship

On the Form your search box should be unbound, not bound to the StudentID field.
What tables are joined and what is the relationships?
 
The tables used for this application are structured as follows:

Student
Student Id - Key
FacultyId - Foregin Key Fac Table
Major - Foregin key Major Table
Minor - Firegin Key on Major Table
etc.

These files are queried and the results are used to produce the student information.

These files are used to produce the grade report found in the subfrom

Roster
Class Id - Key, Foregin key Class Schedule
Section - Key, Forging Key Class Schedule
Student - Key, Foregin key Student File
etc.

These files are queried to produce the grade report. A student can take many different classes during a semester. When I use the student grade form I can see the records for the student and I can use the record navagation keys to move from record to record but if I want to change the student Id and see a specific student I get the record update error because of having related information on the roster file.

The student Id is a long integer on both files
 
If you set the a textbox on the main form to unbound, it will not change anything in the underlying tables. Use the value of that 'search box' in the query to filter your records for that student only. You may have a box to display the studentID but not to change it. Does this make any more sense?
 
clauses

By the sound of your description it appears that you just want to include a search facility on your main form to move to the correct student.

If this is the case I can send you a simple example of this using an unbound text box and command button.

Please let me know if this is what you are after and if so what version A2K or Access 97.

HTH
 
Graham T using your suggestion I keep getting run time error 2162 which tells me I have an error in my find record action argument. What exactly the error is I do not know and have not been able to find any information about. would you like to see a copy of my database so that you can see what I'm doing.
 
Graham T using your suggestion I keep getting run time error 2162 which tells me I have an error in my find record action argument. What exactly the error is I do not know and have not been able to find any information about. would you like to see a copy of my database so that you can see what I'm doing.
 
clauses......

number one....when adding the new combo I suggested you should NOT have removed the StudentID from the form.

second.....

If you send me the database, I will take a look and see what is causing your problems.


MyAvonGirl@aol.com

A2K format and zipped please.
 
clauses

jwindon has kindly offered assistance.

If you still require help, feel free to send me it: graham@nitlc.com

I'm on UK time, so please be patient!

Graham
 
Corrected dbase on its way to you. It will allow you to select the StudentID and will NOT alter your data. I think the problem was basically overkill here. Good luck to you!
 

Users who are viewing this thread

Back
Top Bottom