Reading empty query returns

  • Thread starter Thread starter trekgoes2malaysia
  • Start date Start date
T

trekgoes2malaysia

When I open a form that has a bound query as the record source, no
data appears (including the control objects of the form) if the
query's select statement does not finds records that match the
criteria I specify. This causes a problem in my VBA code as the
variable I use to check the number of records returned by the query
does not seem to be able to read empty query returns, even if I use
isnull. So I guess I am asking how can I get Access to read an empty
result set in VBA from a SQL select statement that is run???

Here is part of my code for this:



DoCmd.OpenForm stDocName2, , , stQuery1

check = (IsNull([Forms]![frmCheckathlete3date]![cntyear].Value))

Thanks for any hep you can provide.
Patrick
 
When I open a form that has a bound query as the record source, no
data appears (including the control objects of the form) if the
query's select statement does not finds records that match the
criteria I specify. This causes a problem in my VBA code as the
variable I use to check the number of records returned by the query
does not seem to be able to read empty query returns, even if I use
isnull. So I guess I am asking how can I get Access to read an empty
result set in VBA from a SQL select statement that is run???

Here is part of my code for this:

DoCmd.OpenForm stDocName2, , , stQuery1

check = (IsNull([Forms]![frmCheckathlete3date]![cntyear].Value))

I'm not sure the form's Load has completed immediately after
the OpenForm line, but try using:

check = Forms!frmCheckathlete3date.Recordset.RecordCount = 0
 
Back
Top