Hiding a Button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've been using code suggested on this board on how to hide a button based on
certain criteria. However, not sure if my problem lies with another issues.
My criteria is based on a field [TotalRecords] which is actually residing in
the forms footer. The control for that field is a Sum([Records]), so it's
not actually calculated until the form is opened and populated. The Button I
want hdden is not hidden and the msg box I placed to check the TotalRecords
value comes back "Count = "

Here's the code, any help is appreciated.

If Me.TotalRecords < 16000 Then
MsgBox "Count = " & (Me![TotalRecords])
Me.Command14.Visible = True
Else
MsgBox "Count = " & (Me.TotalRecords)
Me.Command14.Visible = False
End If
 
Jator said:
I've been using code suggested on this board on how to hide a button based on
certain criteria. However, not sure if my problem lies with another issues.
My criteria is based on a field [TotalRecords] which is actually residing in
the forms footer. The control for that field is a Sum([Records]), so it's
not actually calculated until the form is opened and populated. The Button I
want hdden is not hidden and the msg box I placed to check the TotalRecords
value comes back "Count = "

Here's the code, any help is appreciated.

If Me.TotalRecords < 16000 Then
MsgBox "Count = " & (Me![TotalRecords])
Me.Command14.Visible = True
Else
MsgBox "Count = " & (Me.TotalRecords)
Me.Command14.Visible = False
End If


You can not reliably use VBA code to check the value in a
calculated control. VBA and control calculations are done
in separate, asynchronous computing threads.

The way to do this kibd of check is to calculate the total
either in your VBA code (maybe using DSum) or in the form's
record source query.
 
Thanks Marshall, I had a feeling the calc wasn't being seen by the code. I
decided to roll up in a query and base the form on the lump sum from the
query instead of rolling it up in the form. Seems to work now.

Marshall Barton said:
Jator said:
I've been using code suggested on this board on how to hide a button based on
certain criteria. However, not sure if my problem lies with another issues.
My criteria is based on a field [TotalRecords] which is actually residing in
the forms footer. The control for that field is a Sum([Records]), so it's
not actually calculated until the form is opened and populated. The Button I
want hdden is not hidden and the msg box I placed to check the TotalRecords
value comes back "Count = "

Here's the code, any help is appreciated.

If Me.TotalRecords < 16000 Then
MsgBox "Count = " & (Me![TotalRecords])
Me.Command14.Visible = True
Else
MsgBox "Count = " & (Me.TotalRecords)
Me.Command14.Visible = False
End If


You can not reliably use VBA code to check the value in a
calculated control. VBA and control calculations are done
in separate, asynchronous computing threads.

The way to do this kibd of check is to calculate the total
either in your VBA code (maybe using DSum) or in the form's
record source query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top