How to prevent duplicate records

talktime

Registered User.
Local time
Today, 15:23
Joined
Oct 9, 2011
Messages
11
we have a database of students, where we maintain their particulars specially fee fee history, i.e. which students have paid their fee and who have not yet paid. For this purpose we generate a fee slip every month.


When i click the 'Generate' button on the form, a required fee slip is generated for the selected month and student.
But the problem is that when i click the generate button again the same fee slip is generated again for the same selected month, which i don't want to be so. i want to change this behavior like if fee slip for a particulars month say May or June exists, the duplicate should not be generated if the button is click again and again.
i have provided the sample of Fee Slip Generate 'form' and 'report' to understand the problem.
i have also provided VBA code of the Generate button. please help.
Private Sub Command32_Click()

Dim dbs As Database
Dim Months As Integer
Dim mdate As Date

Set dbs = CurrentDb()
Me.Text26 = CDate("01" & "/" & Month(Me.Text26) & "/" & Year(Me.Text26))
Me.Text28 = CDate("01" & "/" & Month(Me.Text28) & "/" & Year(Me.Text28))
Months = Month(Me.Text26)
mdate = Me.Text26

If Me.Frame0.Value = 1 Then
DoCmd.OpenQuery "School Selected"
ElseIf Me.Frame0.Value = 2 Then
DoCmd.OpenQuery "Class Selected"
ElseIf Me.Frame0.Value = 3 Then
DoCmd.OpenQuery "Class&Section Selected"
ElseIf Me.Frame0.Value = 4 Then
DoCmd.OpenQuery "Student Selected"
End If

'MsgBox& Year(Me.Text28)
DoCmd.OpenQuery "Delete Transport Charges" ' Delete all those record have transport charges but no bus no.
DoCmd.OpenQuery "Delete Free Transport Records" ' Delete all those record have transport charges but FREE.
DoCmd.OpenQuery "Deduct Concession"
DoCmd.OpenQuery "Tuition Fee is zero" ' Delete where tuition fee =0

While mdate <= Me.Text28
dbs.Execute "Update [Tmp School] Set [Tmp School].[Fee Month] = '" & mdate & "'"
DoCmd.OpenQuery "School Append"
mdate = DateAdd("m", 1, mdate)
Wend

DoCmd.OpenQuery "Previous-Final"
dbs.Close

'DoCmd.OpenTable "Generated fee"
Me.Combo15.Enabled = False
Me.Combo19.Enabled = False
Me.Heads_subform.Enabled = False
MsgBox "Fee generated for the reqired Student(s)...", vbOKOnly
End Sub
 

Attachments

  • GeneratedSlip.png
    GeneratedSlip.png
    11.6 KB · Views: 137
  • GenerateForm.png
    GenerateForm.png
    39.6 KB · Views: 135
You could add a field (Y/N) to indicate that a Student Fee and Month has been printed.
You could add a Table to show which records have been Printed.
The issue arises in testing, if you print a test, you need a "procedure" to go in and reset your Print info. This procedure would be a limited Access procedure (eg, not everyone can/could/should run the reset.)
 
Actually the database is created by someone else, he is not with us now, i don't know much about coding and the way concatenation works, if you could do something for me? i can provide the full info if you need to solve this problem.
 

Users who are viewing this thread

Back
Top Bottom