Hello,
I have a continuous form in which I'd like to set the visibility for a button "cmdViewImages" individually for each record on the form.
The form shows the names of a bunch of items in table "Items". The items may or may not have images associated with them in table "Images". If there are Images associated with the item, I want the cmdViewImages button visible.
I'm using this code:
The problem is it only runs the query for the first record on the form and sets the visibility of the button ALL records based on the results for just the first record.
I've tried something similar by instead of running the query, throwing the ItemIDFK from the Image table into the current record and set the visibility based of IsNull(ItemIDFK). Same deal, every record is affected based on the results on the first record. I assume I'm using the wrong event. Any ideas?
I have a continuous form in which I'd like to set the visibility for a button "cmdViewImages" individually for each record on the form.
The form shows the names of a bunch of items in table "Items". The items may or may not have images associated with them in table "Images". If there are Images associated with the item, I want the cmdViewImages button visible.
I'm using this code:
Code:
Private Sub Form_Load()
DoCmd.OpenQuery "qryFindImageByItem", acViewNormal
If DCount("*", "qryFindImageByItem") > 0 Then
Me.cmdViewImages.Enabled = True
Me.cmdViewImages.Visible = True
Else
Me.cmdViewImages.Enabled = False
Me.cmdViewImages.Visible = False
End If
DoCmd.Close acQuery, "qryFindImageByItem", acSaveNo
End Sub
The problem is it only runs the query for the first record on the form and sets the visibility of the button ALL records based on the results for just the first record.
I've tried something similar by instead of running the query, throwing the ItemIDFK from the Image table into the current record and set the visibility based of IsNull(ItemIDFK). Same deal, every record is affected based on the results on the first record. I assume I'm using the wrong event. Any ideas?