On 20 Jul 2004 11:30:49 -0700,
co***@muskoka.com (Colin) wrote:
I have a main form with a command button on it that when clicked,
opens a subform displaying records that relate to the main form.
I would like to disable the command button if the corresponding
subform does not contain a record.
I'm guessing this action would take place in the OnClick event of the
command button but I'm not sure what the VB code is for checking if a
record exists.
Any coding examples and suggestions would be very helpful.
Thanks...CM
You might use the main forms Current event to check if the subform has
any records. (I'm assuming the the "subform" is actually a separate
form, not actually a subform control)
If the basis of the recordsource of the subform is a table and the
related field might be a productID then you could proceed something
like...
Private Sub Form_Current()
Me.cmdButton.Enabled = DCount("*", "tblProds", "ProdID=" _
& Me.ProdID) > 0
End Sub
To do better I would have to know a little more about your forms and
data structure.
- Jim