Jumat, 17 Juli 2020

Re: [MSAccessProfessionals] Access report, need to pass parameters to SQL Server back end

I put the following code in the form's OK button, click event, using Duane's function.  The query property changed as I wanted, but I will got an error saying"run time error 2585.  This action can not be carried out while processing a form or report event" after clicking OK, and debug will lead to the last line code of DoCmd.OpenReport.  The report sometimes does run if I close out and stop the debugger, sometimes doesn't.  I googled and it seems this is the command to open the report. I don't have front end programming experience. What did I do wrong?

Thanks very much!

~ Wei

Private Sub OK_Click()
 
Dim strSQL As String
Dim strOldSQL As String
 
strSQL = "SELECT * FROM vWorkOrders " & _
    "WHERE MaxOfReleaseDate BETWEEN '" & Me.txtStart & "' AND '" & _
    Me.txtEnd & "' "
      
  If Not IsNull(Me.cbQRFType) Then
    strSQL = strSQL & " AND QRFTypeDescr = '" & Me.cbQRFType & "' "
  End If
  
  If Not IsNull(Me.txtClassCode) Then
    strSQL = strSQL & " AND Class = '" & Me.txtClassCode & "' "
  End If
      
strSQL = strSQL & "ORDER BY [SN/LotStart], WorkOrderNo;"
  
strOldSQL = fChangeSQL("Instruments Query", strSQL)
 
DoCmd.OpenReport ReportName:="Instruments Detail Report"
 
 
End Sub
_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#115700) | Reply To Group | Reply To Sender | Mute This Topic | New Topic

Your Subscription | Contact Group Owner | Unsubscribe [sugeng.panjalu.access@blogger.com]

_._,_._,_

Tidak ada komentar:

Posting Komentar