Code: Select all
Private Sub Command0_Click()
If Not CurrentProject.AllForms("frmEnterTransactions").IsLoaded Then
DoCmd.OpenForm ("frmEnterTransactions"), View:=acFormDS
Else
Forms("frmEnterTransactions").Refresh
Forms("frmEnterTransactions").SetFocus
End If
If Not CurrentProject.AllForms("frmOpenPositionsFirst").IsLoaded Then
DoCmd.OpenForm ("frmOpenPositionsFirst"), View:=acFormDS
Else
Forms("frmOpenPositionsFirst").Refresh
End If
If Not CurrentProject.AllForms("frmDailyprof").IsLoaded Then
DoCmd.OpenForm ("frmDailyprof"), View:=acFormDS
Else
Forms("frmDailyprof").Refresh
Forms("frmDailyprof").SetFocus
End If
If Not CurrentProject.AllForms("frmWeekprof").IsLoaded Then
DoCmd.OpenForm ("frmWeekprof"), View:=acFormDS
Else
Forms("frmWeekprof").Refresh
Forms("frmWeekprof").SetFocus
End If
If Not CurrentProject.AllForms("frmMonthprof").IsLoaded Then
DoCmd.OpenForm ("frmMonthprof"), View:=acFormDS
Else
Forms("frmMonthprof").Refresh
Forms("frmMonthprof").SetFocus
End If
If Not CurrentProject.AllForms("frmDividends").IsLoaded Then
DoCmd.OpenForm ("frmDividends"), View:=acFormDS
Else
Forms("frmDividends").Refresh
End If
If Not CurrentProject.AllForms("frmDivByMonth").IsLoaded Then
DoCmd.OpenForm ("frmDivByMonth"), View:=acFormDS
Else
Forms("frmDivByMonth").Refresh
End If
Forms("frmEnterTransactions").Refresh
Forms!frmEnterTransactions!Type.SetFocus
I am having difficulty with this code, its runs but the individual forms don't refresh, as I need to go and select each form and then the select the refresh icon. In addition the second to last command is not executed, the main form FrmEnterTransactions starts off being in focus but the form is sorted newest to oldest and when I had entered some records, hit the "Refresh" command button, the form did not resort the last records entered were still at the bottom of the table. The last command was executed correctly, but All the forms that were coded to be refreshed, none were. What is incorrect?