dbTalk Databases Forums  

Re: Date of Birth Function

comp.database.ms-access comp.database.ms-access


Discuss Re: Date of Birth Function in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bala
 
Posts: n/a

Default Re: Date of Birth Function - 07-31-2003 , 09:29 AM






hi!!!

create a command button name 'Show'

in the click event of the command button

dim sDate as string ' to store date
dim sSQL as string ' to store query
dim rs as new ADODB.Recordset

sdate = trim(txtsearch)

sSQL = "SELECT Count(DOB) from CLIENTS where DOB = #" &
format(sDate,"mm/dd/yyyy") & "#"

if u r using ADO then

rs.cursorlocation = adclient
rs.open sSQL, cn (this being connection object)

with rs
if not(.BOF and .EOF) then
txtResult = rs.fields(1)
end if
end with

hope this helps, sorry if i messed up my explanation or didn't answer
your exact question.

thanx, peace and have a great day

regards
bala

Reply With Quote
  #2  
Old   
Paolo
 
Posts: n/a

Default Re: Date of Birth Function - 08-02-2003 , 02:38 AM






Thanks Ira but I still need some help since I am not familiar with
VBA.
I have tried your code but does not work.
Do I still need two text boxes? WHere do I write the function, add it
to a cmd button to a property of the text box?
Sorry but still need some help.

Ciao.

Ira Solomon <isolomon (AT) solomonltd (DOT) com> wrote

Quote:
Paolo:
You could use a query, but there is an easier way.
Use this function:
DCount(expr, domain, [criteria])

In this case expr is any field in the table.
domain is the name of the table.
criteria looks like:
"dob = " & me.dob

You will get the count without wrting a query.
There are a whole set fo function called "Domain Aggregate Functions"
that are very useful and often neglected.
Look them up .
Good Luck
Ira Solomon
On 31 Jul 2003 03:23:00 -0700, jprma (AT) tin (DOT) it (Paolo) wrote:

Frinds,
I have a table named CLIENTS with a field named DOB in which I have
stored my client's date of birth.
I would now like to create a form (named frmquery) on which add two
tex boxes to run a query so that I can know how many clients I have
with a specific age.

Let's say that the first text box (I'll name it simply txtsearch) will
be used to supply criteria to the query.
The second, named txtresult, should return the number of clients with
the age indicated in txtsearch.

The field on my table has a mm/dd/yyyy format with date property.

My problem is that I do knot know how to write the query criteria or
other.
I know how to write in the query: Like [forms]![frmquery]![txtsearch]
do make the text box ready for the query but do not know how do
actually
create date of birth queries.

Thanks.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.