D
Downie
Scenario:
I have a Main from Branches
I have a Subform BPB inside Branches
Button from previous form to Branches runs the below Filter
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "BRANCHES"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Dim Branch As String
Dim Region As String
Dim Support As String
Dim CDC As String
Dim Admin As String
Dim FLTString As String
Dim SQLString As String
Dim cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim cmd2 As New ADODB.Command
Dim rst As New ADODB.Recordset
Dim rst2 As New ADODB.Recordset
DoCmd.SetWarnings False
Set cnn = CurrentProject.Connection
Set cmd.ActiveConnection = cnn
Set cmd2.ActiveConnection = cnn
FLTString = ""
SQLString = "SELECT views.user_id, views.Branch_Number, users.role
"
SQLString = SQLString & "FROM users LEFT JOIN views ON
users.user_id = views.user_id "
SQLString = SQLString & "WHERE ((users.user_id) = " &
Form_MAIN.user_id.Value & ");"
cmd.CommandText = SQLString
rst.CursorLocation = adUseClient
rst.Open cmd, , adOpenKeyset, adLockOptimistic
' MsgBox (rst.GetString)
'
' MsgBox (Form_MAIN.role)
If rst!role = "Branch" Or rst!role = "Region" Then
SQLString = "SELECT views.user_id, views.Branch_Number "
SQLString = SQLString & "FROM views "
SQLString = SQLString & "WHERE ((views.user_id)= " &
rst!user_id & ");"
'MsgBox (SQLString)
cmd2.CommandText = SQLString
rst2.CursorLocation = adUseClient
rst2.Open cmd2, , adOpenKeyset, adLockOptimistic
' MsgBox (rst2.GetString)
' rst2.MoveFirst
SQLString = "SELECT branches.Branch_Number FROM branches WHERE
"
If rst2.RecordCount > 0 Then
Do While Not rst2.EOF
FLTString = FLTString & "((Branches.Branch_Number) = "
& rst2!Branch_Number & ")"
SQLString = SQLString & "((Branches.Branch_Number) = "
& rst2!Branch_Number & ")"
' MsgBox (SQLString)
' MsgBox (FLTString)
rst2.MoveNext
If Not rst2.EOF Then
FLTString = FLTString & " Or "
SQLString = SQLString & " Or "
End If
Loop
Form_BRANCHES.Filter = FLTString
' MsgBox (SQLString)
Form_BRANCHES.List38.RowSource = SQLString & "ORDER BY
Branch_Number;"
Form_BRANCHES.FilterOn = True
End If
Else
SQLString = "SELECT branches.Branch_Number FROM branches
ORDER BY Branch_Number;"
Form_BRANCHES.Filter = ""
Form_BRANCHES.List38.RowSource = SQLString
Form_BRANCHES.FilterOn = False
End If
Form_BRANCHES.List38.Requery
DoCmd.SetWarnings True
'MsgBox ("DONE")
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
THE Subform BPB inside Branches is running the below code _current()
Private Sub Form_Current()
If Me.updatable_item.Value = True Then
Me.updatable_item.Locked = True
Me.Job_Name.Locked = True
Me.active_jobs_msglog_crtdt.Locked = False
Me.completed_jobs_msglog_crtdt.Locked = False
Me.Failure_Time.Locked = False
Me.Failure_Time.Enabled = True
Me.Actual_Process_time.Locked = True
Me.Estimated_Process_Time.Locked = True
Else
Me.updatable_item.Locked = True
Me.Job_Name.Locked = True
Me.active_jobs_msglog_crtdt.Locked = True
Me.completed_jobs_msglog_crtdt.Locked = True
Me.Failure_Time.Locked = True
Me.Failure_Time.Enabled = False
Me.Actual_Process_time.Locked = True
Me.Estimated_Process_Time.Locked = True
End If
End Sub
So these blocks overlap and cause the Send Error Report to launch
everytime.
IS there any way to maybe tell _Current to wait until the MAIN Branches
form is loaded up?
I have a Main from Branches
I have a Subform BPB inside Branches
Button from previous form to Branches runs the below Filter
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "BRANCHES"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Dim Branch As String
Dim Region As String
Dim Support As String
Dim CDC As String
Dim Admin As String
Dim FLTString As String
Dim SQLString As String
Dim cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim cmd2 As New ADODB.Command
Dim rst As New ADODB.Recordset
Dim rst2 As New ADODB.Recordset
DoCmd.SetWarnings False
Set cnn = CurrentProject.Connection
Set cmd.ActiveConnection = cnn
Set cmd2.ActiveConnection = cnn
FLTString = ""
SQLString = "SELECT views.user_id, views.Branch_Number, users.role
"
SQLString = SQLString & "FROM users LEFT JOIN views ON
users.user_id = views.user_id "
SQLString = SQLString & "WHERE ((users.user_id) = " &
Form_MAIN.user_id.Value & ");"
cmd.CommandText = SQLString
rst.CursorLocation = adUseClient
rst.Open cmd, , adOpenKeyset, adLockOptimistic
' MsgBox (rst.GetString)
'
' MsgBox (Form_MAIN.role)
If rst!role = "Branch" Or rst!role = "Region" Then
SQLString = "SELECT views.user_id, views.Branch_Number "
SQLString = SQLString & "FROM views "
SQLString = SQLString & "WHERE ((views.user_id)= " &
rst!user_id & ");"
'MsgBox (SQLString)
cmd2.CommandText = SQLString
rst2.CursorLocation = adUseClient
rst2.Open cmd2, , adOpenKeyset, adLockOptimistic
' MsgBox (rst2.GetString)
' rst2.MoveFirst
SQLString = "SELECT branches.Branch_Number FROM branches WHERE
"
If rst2.RecordCount > 0 Then
Do While Not rst2.EOF
FLTString = FLTString & "((Branches.Branch_Number) = "
& rst2!Branch_Number & ")"
SQLString = SQLString & "((Branches.Branch_Number) = "
& rst2!Branch_Number & ")"
' MsgBox (SQLString)
' MsgBox (FLTString)
rst2.MoveNext
If Not rst2.EOF Then
FLTString = FLTString & " Or "
SQLString = SQLString & " Or "
End If
Loop
Form_BRANCHES.Filter = FLTString
' MsgBox (SQLString)
Form_BRANCHES.List38.RowSource = SQLString & "ORDER BY
Branch_Number;"
Form_BRANCHES.FilterOn = True
End If
Else
SQLString = "SELECT branches.Branch_Number FROM branches
ORDER BY Branch_Number;"
Form_BRANCHES.Filter = ""
Form_BRANCHES.List38.RowSource = SQLString
Form_BRANCHES.FilterOn = False
End If
Form_BRANCHES.List38.Requery
DoCmd.SetWarnings True
'MsgBox ("DONE")
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
THE Subform BPB inside Branches is running the below code _current()
Private Sub Form_Current()
If Me.updatable_item.Value = True Then
Me.updatable_item.Locked = True
Me.Job_Name.Locked = True
Me.active_jobs_msglog_crtdt.Locked = False
Me.completed_jobs_msglog_crtdt.Locked = False
Me.Failure_Time.Locked = False
Me.Failure_Time.Enabled = True
Me.Actual_Process_time.Locked = True
Me.Estimated_Process_Time.Locked = True
Else
Me.updatable_item.Locked = True
Me.Job_Name.Locked = True
Me.active_jobs_msglog_crtdt.Locked = True
Me.completed_jobs_msglog_crtdt.Locked = True
Me.Failure_Time.Locked = True
Me.Failure_Time.Enabled = False
Me.Actual_Process_time.Locked = True
Me.Estimated_Process_Time.Locked = True
End If
End Sub
So these blocks overlap and cause the Send Error Report to launch
everytime.
IS there any way to maybe tell _Current to wait until the MAIN Branches
form is loaded up?