How to Make Bold a Command Button Bold If Related Table Has Data

  • Thread starter Thread starter doyle60
  • Start date Start date
D

doyle60

What is the best procedure to make a command button bold if an
unrelated table---one not drawn up in a subform or into the query the
form is based on---has a related record.

The Main Form:
Record Source: OrderHeaderqry
The Key Field: PO (Text)

The Unrelated Table:
CompPOListtbl
The Key Field: CompPO (Text)

So when I am on the main form and I move to a new record (say) PO
12222 and if there is a 12222 in the CompPO field of the
CompPOListtbl, I want the Command5425 button to be bold. If there is
not a 12222, I want Command5425 to be normal.

I had this working using an invisible sub and an invisible field on
the main to bring in the number of lines on the invisible sub and
having this on current code:

If CountOfCompPOID2 = 1 Then
Command5425.FontWeight = 700
Else
Command5425.FontWeight = 400
End If

And if worked beautifully. But when I signed on as a user that did
not have permission on the subform data, I got an error. So I need to
rethink this and get a bit smarter.

So can I do this with just code (and without bringing the
CompPOListtbl table into the OrderHeaderqry query)?

Thanks,

Matt
 
You might be able to use the DCOUNT function in the Current Event of the
form.

If DCount("*","ComPOListTbl","CompPO=""" & Me.PO & """") >0 Then
Command5425.FontWeight = 700
Else
Command5425.FontWeight = 400
End If

if the CompPO is a number field (not a text field containing number
characters) then you need to modify the DCount function to

DCount("*","ComPOListTbl","CompPO=" & Me.PO)

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
Back
Top