Hey there...
I have a form which I use for a switch board. The form as a button which when selected, opens a new form that is called frmToDoListing. This form has a list box which displays all my open todo items, based on a query. From this form, I can then select one of the todo items or select a New button which opens another form, frmtoDoEntry, which I can then mark a todo item completed, or make a new one. When I close the frmtoDoEntry, it returns to the previous form, frmToDoListing, and it refreshes to remove any newly closed todo items, or will show the newly added todo items. I close this form, and then I am back to the SwitchBoard form. While this all happens, the SwitchBoard form is in the background; its not closed.
I have this code which redoes the font on the toDo button on the switchboard form, which tells me there are open todo items and should be looked at. When there are no open todo items, the button is displayed with a normal font, letting me knownothing needs to be looked at. here is the code:
Private Sub Form_GotFocus()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String
Dim db1 As DAO.Database
Dim rs1 As DAO.Recordset
Dim strSql1 As String
Set db = CurrentDb
strSql = "Select Count(*) As OpenRecs from tblToDo Where IsNull(txtDateCompleted)"
Set rs = db.OpenRecordset(strSql)
If rs!Openrecs > 0 Then
Me.btnToDoListing.ForeColor = vbRed
Me.btnToDoListing.FontSize = 14
Else
Me.btnToDoListing.ForeColor = vbBlue
Me.btnToDoListing.FontSize = 8
End If
End Sub
The code works fine as long as you close and reopen the switchboard form. However, this code will not work when I close the frmToDoListing form, which places the switchboard form as the only form open, and thus placing the focus back on it.
Am I doing this wrong, or am I not understanding what the GotFocus optin is suppose to be used for? Is the only option to close and reopen the switchboard form?
thanks in advance!
Richard
I have a form which I use for a switch board. The form as a button which when selected, opens a new form that is called frmToDoListing. This form has a list box which displays all my open todo items, based on a query. From this form, I can then select one of the todo items or select a New button which opens another form, frmtoDoEntry, which I can then mark a todo item completed, or make a new one. When I close the frmtoDoEntry, it returns to the previous form, frmToDoListing, and it refreshes to remove any newly closed todo items, or will show the newly added todo items. I close this form, and then I am back to the SwitchBoard form. While this all happens, the SwitchBoard form is in the background; its not closed.
I have this code which redoes the font on the toDo button on the switchboard form, which tells me there are open todo items and should be looked at. When there are no open todo items, the button is displayed with a normal font, letting me knownothing needs to be looked at. here is the code:
Private Sub Form_GotFocus()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String
Dim db1 As DAO.Database
Dim rs1 As DAO.Recordset
Dim strSql1 As String
Set db = CurrentDb
strSql = "Select Count(*) As OpenRecs from tblToDo Where IsNull(txtDateCompleted)"
Set rs = db.OpenRecordset(strSql)
If rs!Openrecs > 0 Then
Me.btnToDoListing.ForeColor = vbRed
Me.btnToDoListing.FontSize = 14
Else
Me.btnToDoListing.ForeColor = vbBlue
Me.btnToDoListing.FontSize = 8
End If
End Sub
The code works fine as long as you close and reopen the switchboard form. However, this code will not work when I close the frmToDoListing form, which places the switchboard form as the only form open, and thus placing the focus back on it.
Am I doing this wrong, or am I not understanding what the GotFocus optin is suppose to be used for? Is the only option to close and reopen the switchboard form?
thanks in advance!
Richard