When I select courses in the SUBJECT enrolld List (List Box), the count either doesn’t show or shows incorrectly. How can I fix this? Please guide.

moin555

Member
Local time
Today, 12:29
Joined
Feb 6, 2025
Messages
34
Second question: I want to design a monthly fee voucher where, with one click, the monthly fee slips for all students are generated and saved as PDFs
1745646820619.png
 
I do not get that error?
1745650740184.png


Functions generally return a value, as Subs do not. That function is not returning a value.?
A DCount() would count what should be the number of records (courses) for each student.
Not sure how you are doing it, as I have to go out now.
Also give your command buttons meaningful names.

As for a pdf document for each student, here is how I did similar for a DB of mine, basically a recordset of records required, then a report for each one where the report is filtered for each record.

Code:
Private Sub cmdShip_Click()
On Error GoTo Err_cmdShip_Click

    Dim stRptName As String, stParam As String, stLinkCriteria As String, stDBpath As String, stFTPpath As String
    Dim iPreview As Integer, iDialog As Integer, blnPrintIt As Boolean
    
    stDBpath = CurrentProject.Path & "\"
    stFTPpath = stDBpath & "Gazette\"
    iPreview = acViewPreview
    If Me.ChkPreview Then
       ' iPreview = 2
        iDialog = acWindowNormal
    Else
        iDialog = acHidden
    End If
    
    stRptName = "Main_by_Ship"
    
    stParam = Replace(LCase(Me.cboShip.Value), " ", "_")
    stLinkCriteria = "[Ship] = '" & Me.cboShip.Value & "'"
    
    'DoCmd.CopyObject , stParam, acReport, stRptName
        
    If Me.ChkPreview Then
        DoCmd.OpenReport stRptName, iPreview, , stLinkCriteria, iDialog
    Else
        DoCmd.OpenReport stRptName, iPreview, , stLinkCriteria, iDialog
        DoCmd.OutputTo acOutputReport, stRptName, acFormatPDF, stFTPpath & stParam & ".pdf", False
        DoCmd.Close acReport, stRptName
    End If
    'DoCmd.DeleteObject acReport, stParam

Exit_cmdShip_Click:
    Exit Sub

Err_cmdShip_Click:
    MsgBox Err.Description
    Resume Exit_cmdShip_Click
    
End Sub
 
I do not get that error?
View attachment 119585

Functions generally return a value, as Subs do not. That function is not returning a value.?
A DCount() would count what should be the number of records (courses) for each student.
Not sure how you are doing it, as I have to go out now.
Also give your command buttons meaningful names.

As for a pdf document for each student, here is how I did similar for a DB of mine, basically a recordset of records required, then a report for each one where the report is filtered for each record.

Code:
Private Sub cmdShip_Click()
On Error GoTo Err_cmdShip_Click

    Dim stRptName As String, stParam As String, stLinkCriteria As String, stDBpath As String, stFTPpath As String
    Dim iPreview As Integer, iDialog As Integer, blnPrintIt As Boolean
  
    stDBpath = CurrentProject.Path & "\"
    stFTPpath = stDBpath & "Gazette\"
    iPreview = acViewPreview
    If Me.ChkPreview Then
       ' iPreview = 2
        iDialog = acWindowNormal
    Else
        iDialog = acHidden
    End If
  
    stRptName = "Main_by_Ship"
  
    stParam = Replace(LCase(Me.cboShip.Value), " ", "_")
    stLinkCriteria = "[Ship] = '" & Me.cboShip.Value & "'"
  
    'DoCmd.CopyObject , stParam, acReport, stRptName
      
    If Me.ChkPreview Then
        DoCmd.OpenReport stRptName, iPreview, , stLinkCriteria, iDialog
    Else
        DoCmd.OpenReport stRptName, iPreview, , stLinkCriteria, iDialog
        DoCmd.OutputTo acOutputReport, stRptName, acFormatPDF, stFTPpath & stParam & ".pdf", False
        DoCmd.Close acReport, stRptName
    End If
    'DoCmd.DeleteObject acReport, stParam

Exit_cmdShip_Click:
    Exit Sub

Err_cmdShip_Click:
    MsgBox Err.Description
    Resume Exit_cmdShip_Click
  
End Sub
 
So given that both @arnelgp and @Gasman reported that the error was not raised when they used the application that you now need to do some investigation: look at the error message: What was the user defined function in After Update that cannot be found? Where did the UDF come from? Can you investigate and provide information to help yourself?
 
So given that both @arnelgp and @Gasman reported that the error was not raised when they used the application that you now need to do some investigation: look at the error message: What was the user defined function in After Update that cannot be found? Where did the UDF come from? Can you investigate and provide information to help yourself?
i try but i am not find
 
Can you look at the properties of the list box, check the Event After update associated with it - and look at the vba? Can you set a Breakpoint at the start of the vba in that event and step thru the code: using <Fn - F8> until the error is triggered? What is the code on that line? Did you not write it - or copy it?
 
Can you look at the properties of the list box, check the Event After update associated with it - and look at the vba? Can you set a Breakpoint at the start of the vba in that event and step thru the code: using <Fn - F8> until the error is triggered? What is the code on that line? Did you not write it - or copy it?
can you check sir
 

Attachments

Can you look at the properties of the list box, check the Event After update associated with it - and look at the vba? Can you set a Breakpoint at the start of the vba in that event and step thru the code: using <Fn - F8> until the error is triggered? What is the code on that line? Did you not write it - or copy it?
1745663274115.png

In the form

Code:
Option Compare Database
Option Explicit

Public Function UpdateSubjCount()
Me.Dirty = False
Me.txtSubjectCount.Requery
Call Form_Current
End Function

Private Sub Form_Current()
If Nz(Me.Total_Fee, 0) <> (Nz(Me.txtSubjectCount, 0) * Nz(Me.subject_Fee, 0)) Then
    Me.Total_Fee = Nz(Me.txtSubjectCount, 0) * Nz(Me.subject_Fee, 0)
    Me.Dirty = False
End If
End Sub
 
have you downloaded the db in post #9.
on my test on that db, there is no error.
 

Users who are viewing this thread

Back
Top Bottom