Payment Query

  • Thread starter Thread starter jkjmwilliams
  • Start date Start date
J

jkjmwilliams

I have a form with StudentInfo, PaymentInfo subform, and CompletionInfo
subform. We invoice a certain customer and then go back and fill out the
payment information when the client pays.

I tried to run a query so that I could make all the updates without having
to do a control find on each and every one of them. I can pull up the list of
students from StudentInfo, but when I add in the PaymentInfo, I get nothing
because there is nothing there.

Is there any way I can make the null PaymentInfo to pull up with the
StudentInfo so we can fill this out w/o doing a Ctrl/Find?

JoAnn
 
Do you have the equivalent of the following fields in your tables?

Student Table
Primary Key StudentID

PaymentInfo
PrimaryKey PayID
Foreign Key Student ID

CompletionInfo
Primary Key CompletionID
Foreign Key Pay ID
(StudentID should not be in this table unless the student who completes the
Payment is different from the student who initially starts the record in
PaymentInfo)

If you have this structure then your first subform (PaymentInfo) will be
linked to StudentID and as soon as you enter anything into it then you will
get your record. You will then have code in you PaymentInfo sub to Requery
your Completion Info sub so that it is on the correct record for your
student)
Your CompletionInfo Sub should be linked to your PaymentInfo sub

Is this the structure which you have?

Evi
 
No, I don't have that structure. If I change it, will it work for the past
records?
 
I changed my table structure, and indexed PaymentId to Yes(No Duplicates).
Then, I copied and pasted all the StuID's into the PaymentId field to
populate that field. Still no luck. Could it be the referencial integrity
thing? I am unable to use that option in the relationship. How do I enforce
that?
 
Here is my table structure:
StudentInfo: StuId; FirstName; LastName; (All the other standard info);
Agency; Course1; MethodOfStudy; ClassDate; Paid (Y/N); Amount; Course2;
(etc)...

PaymentInfo:
PaymentID; StudentID; Course1; DatePaid; MethodOfPayment; Course2; (etc)...

(Some people will sign up for and pay for a course on one date; and then
later, sign up and pay for another course.)
 
Hi JK,
Sorry, its still not right. If a student can take more that 1 course and
pays for them seperately you'll need to change again. Just ensure that you
backup and backup as you normalize your db so that you can refer back if it
does go like you expect and so that you can check that you have matched up
the data

Your Course 1, Course 2 fields should not exist. (If your college ever
offered 3 courses, you would have to change your entire database and all
your forms reports and queries)

Instead, you should have

StudentInfo
StuID, FirstName, LastName etc stuff only to do with the student and nothing
about the courses

TblCourse
CourseID
CourseName
CourseStartDate
Otherstuff all about the course and nothing to do with the student
So if ClassDate is something is the same for all students then it would go
here. If individual students have different dates then the StudentCourses
table would have it.


TblPaymethod
MethID
PayMethod (if you want to enter all students and courses into TblPayment
even before they have paid, then make the first entry in this None and use
that ID number as the default value for MethID in TblPayment)


for the next bit there are 2 options You can combine TblStudentCourses and
TblPayment into one Table but ONLY if students only ever make one payment
for each course. If they ever make part-payements (or are *ever* likely to
do so in the future) you will need to record the details of each
part-payment eg the date it was paid, how much was paid, how it was paid.

TblStudentCourses
SCID (Primary Key)
StuID
CourseID
Details to do with that student and that course - perhaps when he signed up
for it
TotalCost (the total cost of *that course* for *that student*- if there is a
standard cost for the course for all students, then this field would go in
TblCourse.


TblPayment
PaymentID PK
(this is connected to the student paying for one of the courses he is taking
so)
SCID (a combo box to feed this field could concatenate StudentName and
Course and would be based on a query based on TblStudentCourse which had the
text fields from StudentInfo and TblCourse )
PayDate
PayAmount
MethID (so you can choose which method of payment he is using -
ChkNo (check number if he is paying by check
Other fields concernin the student's payments for that course.

Using this latter structure, you can record if and when students made a part
payment for the course.
In forms, queries and reports you can calculate both how much the student
has paid for each course, how much he is owing for each course and how much
he owes altogether.

(I don't know whether MethodOfStudy is dictated by the Course - in which
case it goes in TblCourse, or if it is the choice of the student, in which
case it goes in StudentCourses)

CompletionInf
If this has the details of the student completing the course then it will
have
CompID
SCID
CompletionDate
any info which refers to that student completing that course.

You won't be able to (nor will you need to) enforce Referential Integrity
until all the records in the Foreign Key field (eg StuID in
TblStudentCourse) have been filled in with a StuID number that is in the
TblStudent. Referential Integrity means that you won't be allowed to finish
entering a new record into eg TblStudentCourse until you have chosen a StuID
from StudentInfo and a CourseID from TblCourse

You won't want to enforce Ref Integ until everything has been sorted out.
For all your Foreign Key fields, ensure that they are Number and Long
Integers and delete the Default Value of 0.

In some cases, you may want a Default Value to correspond to a 'dummy
record' in the 'one' table (one tables above are StudentInfo, TblCourse,
TblPaymethod)
So, for example, you may want to append all students and their courses to
TblPayment using an Append query to append all the SCIDs and then fill in
their payments when they make them, If you do this, you would want a Dummy
record for MethID (N/A or None) and you would have that MethID as the
Default Value for MethID in TblPayment

You may want to check what you have entered since you will only see a load
of ID numbers instead of real data.

To do this, if you were using the structure above, you would start of with
TblStudentCourse. You would put create a form based on TblStudentCourse
alone.
You would have a combo based on a query based only on TblStudent and bound
to StuID. You can concatenate eg FirstName and Surname in the query. Another
combo would be based on TblCourse and be bound to CourseID.

Or

You could have a main table based on TblStudent and the Subform based on
TblStudentCourse and having a combo box based on TblCourse

For the payments, you would have a main form based on TblStudent, a First
subform based on TblStudentCourse and a second subform based on tblPayment
and linked to the First Subform by SCID.

Evi
 
Wow! That was soooo helpful. It will take some time to straighten it all out,
but I will take your advise and go to work on it. It makes sense to me. Thank
you for taking the time to write all that. I have been working on a backup
copy to try to get this to work, so I won't harm the original data. Thanks
again for your advise.

JoAnn
 
I've thought further on this.
You need to put the AmountOwing into the Student Course table although you
can have a Price list in the Courses table. The Price List may change but
what the Student was charged when he signed up, must remain the same. We can
help you to code the form so that when you fill in the Student and Course,
it looks up the current Price for that Course and copies it into Amount
Owing.

Also
I'm guessing that MethodOfStudy means stuff like Full time course, Part time
course Correspondance.
If I am right, then this will also effect the structure because your Price
List will probably be different for each of the Study Methods

If this latter is the case then the structure would be


TblCourse
CourseID (Primary Key)
CourseName eg Primary English, Advanced Maths
CourseStartDate (this may need to be in the CourseMethod table if different
study methods start on different dates)
CourseEndDate

TblStudyMethod
StudMethID (PK)
StudyMethod (eg Part Time, Full Time)

TblStudent
StuID (PK)
FName
SName
Sex
DOB
Address
etc

TblPayMethod
PayMethID
PaymentMethod (eg Cheque, Cash, Credit Card)


TblCourseMethod
CrsMethID (PK)
CourseID
StudMethID (a combo based on this table will concatenate the CourseName with
the StudyMethod
CCost (Cost of this course using this study method)

TblStudentCourse
SCID (PK)
StuID
CrsMethID
EnrolDate
StudMethID
AmountDue (that's the amount due for that particular course-and-studymethod)
DatePayDue (the date by which the student must pay for that course)
I'm playing around with keeping your Yes/No Paid field - it isn't strictly
necessary because Paid will be when PayAmount totals CCourse but you could
aways keep it for now and just not use it if it proves superfluous

TblPayment
PayID (PK)
PayDate (date payment was made
SCID
PayMethID
PayAmount (amount paid on this occasion)
PayComments (any notes about this payment)
ProofNumber (eg Check number, CreditCard number, Receipt number for cash
payments - this may have to be a text field if some of these have leading 0s
ProofDetail eg Card expiry date, SortCode


(These last 2 will be different according to your needs and may be more
numerous ie you may want a specific field for CardNumber or SortCode and you
will use Code in your form so that if the user Selects eg CreditCard as the
Payment Method, the appropriate fields become obligatory and the user is
reminded to fill them in before they leave the record)

A few design tips which have helped me: Keep your field names short but
meaningful and without symbols or spaces and avoiding Reserved Words like
Time, Date, Name - your labels in reports or forms can show whatever you
like.
Do use the Description line in Table Design. It will show up in the status
bar and remind you what the heck you intended to do with this field.

I've had a surprising amount of irritation with myself when I've chosen a
wrong name and found it confusing when I was trying to use it.
Don't spent ages tarting up a form until you are really sure that your
database works as you wish.
Test putting dummy data into your database.

I do hope this gives you a basic idea. You will certainly make many changes
before you have finished.
Evi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top