Has anyone experienced problems with Me.Refresh not working?
I have a couple procedures on a form where the form needs to refresh after running code. For one procedure, it always works. For the other, it doesn't.
I need this primarily to update a field that shows the number of records in a table (Dcount). This should show a number of records after the first procedure (importing) and change to zero after the second (rolling up to the YTD table). Or is it because I am testing and running both procedures one after another (in the user environment, they wouldn't be doing that).
Grasping at straws to figure it out...
Here's the code (abbreviated):
************************************
Private Sub cmdRollUp_Click()
On Error GoTo Err_cmdRollUp_Click
DoCmd.SetWarnings False
If MsgBox("Data will be moved from Proof/Commission tables to YTD tables. Current tables will be cleared (along with BP table). Continue?", vbYesNo, "Are you sure?") = vbNo Then
Exit Sub
Else
***[multiple queries run to update the tables; these do run fine]***
MsgBox "RollUp Complete! Sales Rep report will appear if new sales reps were found", vbOKOnly, "Roll-Up Data"
DoCmd.OpenReport "SalesReps", acViewPreview, , "[salesrep] is null"
End If
DoCmd.SetWarnings True
Me.Refresh ***[this one does not work. ]****
Exit_cmdRollUp_Click:
Exit Sub
Err_cmdRollUp_Click:
If Err.Number = 2501 Then
Else
MsgBox Err.Number & "-" & Err.Description
End If
Resume Exit_cmdRollUp_Click
End Sub
'---------------------------------------------------------
Private Sub cmdImport_Click()
On Error GoTo Err_cmdImport_Click
Dim strqueryname As String
Dim strobjectname As String
Dim strtable As String
Dim intcount As Integer
DoCmd.SetWarnings False
Select Case optImport
Case 1
**code**
Case 2
**code**
Case 3
**code**
End Select
If intcount > 0 Then
MsgBox strtable & " should be rolled up to YTD before importing new data", vbExclamation, strtable & " table is not empty!"
Exit Sub
End If
If MsgBox("Are you sure you want to import new " & strtable & " data?", vbYesNo, "Import " & strtable & " data") = vbYes Then
DoCmd.RunCommand acCmdImport
DoCmd.OpenQuery strqueryname
DoCmd.DeleteObject acTable, strobjectname
MsgBox "Import of " & strtable & " data is complete!", vbOKOnly, strtable & " Import"
Else
Exit Sub
End If
DoCmd.SetWarnings True
Me.Refresh **[this works ]***
Exit_cmdImport_Click:
Exit Sub
I have a couple procedures on a form where the form needs to refresh after running code. For one procedure, it always works. For the other, it doesn't.
I need this primarily to update a field that shows the number of records in a table (Dcount). This should show a number of records after the first procedure (importing) and change to zero after the second (rolling up to the YTD table). Or is it because I am testing and running both procedures one after another (in the user environment, they wouldn't be doing that).
Grasping at straws to figure it out...
Here's the code (abbreviated):
************************************
Private Sub cmdRollUp_Click()
On Error GoTo Err_cmdRollUp_Click
DoCmd.SetWarnings False
If MsgBox("Data will be moved from Proof/Commission tables to YTD tables. Current tables will be cleared (along with BP table). Continue?", vbYesNo, "Are you sure?") = vbNo Then
Exit Sub
Else
***[multiple queries run to update the tables; these do run fine]***
MsgBox "RollUp Complete! Sales Rep report will appear if new sales reps were found", vbOKOnly, "Roll-Up Data"
DoCmd.OpenReport "SalesReps", acViewPreview, , "[salesrep] is null"
End If
DoCmd.SetWarnings True
Me.Refresh ***[this one does not work. ]****
Exit_cmdRollUp_Click:
Exit Sub
Err_cmdRollUp_Click:
If Err.Number = 2501 Then
Else
MsgBox Err.Number & "-" & Err.Description
End If
Resume Exit_cmdRollUp_Click
End Sub
'---------------------------------------------------------
Private Sub cmdImport_Click()
On Error GoTo Err_cmdImport_Click
Dim strqueryname As String
Dim strobjectname As String
Dim strtable As String
Dim intcount As Integer
DoCmd.SetWarnings False
Select Case optImport
Case 1
**code**
Case 2
**code**
Case 3
**code**
End Select
If intcount > 0 Then
MsgBox strtable & " should be rolled up to YTD before importing new data", vbExclamation, strtable & " table is not empty!"
Exit Sub
End If
If MsgBox("Are you sure you want to import new " & strtable & " data?", vbYesNo, "Import " & strtable & " data") = vbYes Then
DoCmd.RunCommand acCmdImport
DoCmd.OpenQuery strqueryname
DoCmd.DeleteObject acTable, strobjectname
MsgBox "Import of " & strtable & " data is complete!", vbOKOnly, strtable & " Import"
Else
Exit Sub
End If
DoCmd.SetWarnings True
Me.Refresh **[this works ]***
Exit_cmdImport_Click:
Exit Sub