....but only when more than one user is logged into the database.
Access 2000 formatted tables.
Code from a form to generate SQL then open a specific report; the report takes the SQL and uses it as recordsource. Here first is the code behind the form, frmActive
And now the code behind the report, rptActiveFiles
So the question - why, in my development copy, would this procedure work perfectly, but in the live copy where multiple users are logged in, I get the 2501 runtime error? When I debug, the docmd.openreport line is highlighted on frmActive. Any ideas? Thank you in advance.
~Melagan
______
"It's never too late to become what you might have been.
Access 2000 formatted tables.
Code from a form to generate SQL then open a specific report; the report takes the SQL and uses it as recordsource. Here first is the code behind the form, frmActive
Code:
Sub cmdOK_Click()
Dim strDocName As String
Dim strSQL As String
gstrActiveSQL = "" 'Global variable in modPublic
strDocName = "rptActiveFiles"
If Me.optLennar.Value = -1 Then
gstrActiveSQL = "SELECT e.[Escrow Number], e.[Escrow Status], u.First_Last, e.[Opening Date], e.PDC,"
gstrActiveSQL = gstrActiveSQL + " e.[PDC Broker], u.[Last Name]"
gstrActiveSQL = gstrActiveSQL + " FROM tblUsers u INNER JOIN Escrows e on u.Initials = e.[EO Initials]"
gstrActiveSQL = gstrActiveSQL + " WHERE u.Title='Escrow Officer' AND (u.Function='Escrow'"
gstrActiveSQL = gstrActiveSQL + " Or u.Function='Lennar') AND e.[Recording Status]='In Progress'"
gstrActiveSQL = gstrActiveSQL + " AND e.[Escrow Status] Not Like '*Cancelled*'"
Else
gstrActiveSQL = "SELECT e.[Escrow Number], e.[Escrow Status], u.First_Last, e.[Opening Date], e.PDC,"
gstrActiveSQL = gstrActiveSQL + " e.[PDC Broker], u.[Last Name]"
gstrActiveSQL = gstrActiveSQL + " FROM tblUsers u INNER JOIN Escrows e on u.Initials = e.[EO Initials]"
gstrActiveSQL = gstrActiveSQL + " WHERE u.Title='Escrow Officer' AND (u.Function='Escrow'"
gstrActiveSQL = gstrActiveSQL + " Or u.Function='Lennar') AND e.[Recording Status]='In Progress'"
gstrActiveSQL = gstrActiveSQL + " AND e.[Escrow Status] Not Like '*Cancelled*'"
gstrActiveSQL = gstrActiveSQL + " AND IIF([Escrow Status] = 'New Home', -1, 0) = 0"
End If
DoCmd.OpenReport strDocName, acViewPreview
DoCmd.SelectObject acReport, strDocName, False
DoCmd.Maximize
End Sub
And now the code behind the report, rptActiveFiles
Code:
Option Compare Database
Option Explicit
Private m_RowCount As Long
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
m_RowCount = m_RowCount + 1
If m_RowCount / 2 = CLng(m_RowCount / 2) Then
Me.Detail.BackColor = 16638405 'Change value to the color you desire
Else
Me.Detail.BackColor = 14013909 'Change value to the color you desire
End If
DoCmd.Close acForm, "frmActive"
End Sub
Private Sub Report_Close()
DoCmd.SelectObject acForm, "frmSwitchBoard", False
DoCmd.Restore
End Sub
Private Sub Report_NoData(Cancel As Integer)
On Error GoTo ErrorHandler
MsgBox "There are currently no records.", vbOKOnly, "No Records"
Cancel = True
DoCmd.Close acForm, "frmActive"
ExitHandler:
Exit Sub
ErrorHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub
Private Sub Report_Open(Cancel As Integer)
Me.RecordSource = gstrActiveSQL
End Sub
So the question - why, in my development copy, would this procedure work perfectly, but in the live copy where multiple users are logged in, I get the 2501 runtime error? When I debug, the docmd.openreport line is highlighted on frmActive. Any ideas? Thank you in advance.
~Melagan
______
"It's never too late to become what you might have been.