Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using the value from a count query

Status
Not open for further replies.

RobTsintas

Technical User
May 17, 2001
58
GB
I have created a query that successfully counts the number of records whose ID is the same as the value entered in a form's ID field.

What I want to do now is to use the AfterUpdate event of the form's ID field to look at the count value from the query, so that the user can be instantly alerted if that ID already exists.

I cannot, for the life of me, work out how to refer to the query's count field using VB Code.

(There isn't a 'Queries!' qualifier, like there is for 'Forms!' and 'Reports!', is there?)

Alternatively, if you can think of a better way to do what I need, tell me that instead.

Thanks.
 
just make an assignment statement ~~

mytextbox = rstRecSet!CountField

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
...which I put where?

My Query is called qry_IDCheck, and the count field in the Query is called CountOfID, and I have declared a variable called IDCount in the AfterUpdate expression. I tried adding this line:

IDCount = rstRecSet!CountOfID

but just get a 'variable not defined' error. Am I putting this in the wrong place, or have I translated it incorrectly?

Thanks for your help.

P.S. I am using Access 97
 
qry_IDCheck, and the count field in the Query is called CountOfID, and I have declared a variable called IDCount in the AfterUpdate expression. I tried adding this line:

IDCount = rstRecSet!CountOfID

Looks o.k. -as far as it goes. You do need to have declared the db and recordset as well as instantiated them within the scope of the procedure to use it this way, but it should work. The err implies that the db and rst are not properly instantiated.


MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top