null recordset

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

Guest

i have a command that opens a form which shows all products for a particular
client. what i want to achieve is to set an error message when the view
products button is clicked and there are no products in the form. (the user
adds the products and then these can be viewed and edited, a different cmd
button is used for adding products).

can anyone help.

thanks

richard
 
Richard,
I'd suggest not allowing the ViewProducts button to be enabled until
there are records to View. Better to prevent an error than code to recover
from one.
Try a DSum on the OnCurrent event of the form to Enable or Disable the
View button.
Something like...
If DCount( of your records) < 1 or IsNull(DCount( the same)) Then
cmdView.Enabled = True
Else
cmdView.Enabled = False
End If
Didn't test, but that should do it.
 
richard said:
i have a command that opens a form which shows all products for a particular
client. what i want to achieve is to set an error message when the view
products button is clicked and there are no products in the form. (the user
adds the products and then these can be viewed and edited, a different cmd
button is used for adding products).


You can check if the form's RecordsetClone's RecordCount
property has a value of zero. How you would do that depends
on the specifics of your forms. If the products form is a
separate form, then it should be done in the form's Load
event. If it's a subform, then you can check it after the
subform control's SourceObject or RecordSource property is
set.
 
hi, i tried this and it worked whilst i only had one client in the database,
but as soon as i had more than one client (as there would be products for
this client in the underlying query) it did not work.

how would i apply a filter on the onload event of the edit products form, so
if there are no products for that specific client then the code would work.

thanks in advance. richard
 
you need to specify which client in the criteria clause of the DCount
function.

Brian
 
Back
Top