Results 1 to 1 of 1
  1. #1
    Join Date
    Oct 2011
    Posts
    4

    Unanswered: How to prevent duplicate record to generate

    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
    Attached Thumbnails Attached Thumbnails GeneratedSlip.png   GenerateForm.png  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •