Full Version: Hidden Or Background Queries?
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
TangSooTony
Not sure if this would qualify as a Query or Form question, but here goes...

I have a form called Menu with a button called Followup.
Button Followup opens a form called Followup which retrieves date from a query called, wait for it... Followup

What I would like to happen:

When form Menu loads I would like it to run query Followup (invisible to user) and return a record count
If the record count is > 1 then modify the property of button Followup on the form Menu (make it red, bold, whatever)

Simply put I want the user to be able to see if any records require Followup without having to click the button


I've googled to no avail, any assistance would be greatly appreciated iconfused.gif

Thanks
River34
First of all, you cannot change the color of a command button on a form. You can, however, draw a rectangle around it. Use a hefty border size (2) and make it red.
When the form opens, set Me.RectangleName.visible = false

Now to make this show up when there aren't any records place the following on the OnOpen Event for the form Menu

Set rs = db.OpenRecordset("YourQueryName")
If rs.RecordCount = 0 Then
Me.Followup.Rectangle.Visible = True
End if
Set rs = nothing

Another suggestion is to just open a message box telling the user there aren't any records.

Set rs = db.OpenRecordset("YourQueryName")
If rs.RecordCount = 0 Then
Msgbox "There are no records needing to be followed up at this time.", vbokonly
End if
Set rs = nothing

Hope these give you some ideas.
TangSooTony
thanks! checked out your code and did some more googling based on what you posted and ended up with this:

Private Sub Form_Current()

Me.boxFollowup.Visible = False <-- boxFollowup is a red rectangle like you suggested, gives the button a thick red border

Set db = CurrentDb()
Set rs = db.OpenRecordset("qryFollowup")
If rs.RecordCount > 0 Then
Me.boxFollowup.Visible = True
End If

Set rs = Nothing

End Sub

Does exactly what i need it to. thanks for the help! i'll be back for more i'm sure iconfused.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.