|
-
Jul 8th, 2005, 06:44 AM
#1
Thread Starter
Lively Member
birthdays!
i have a date field in my databse in format mm/dd/yyyy
how do i find if someone is having their birthday based on today's date in the databse when the form loads.
how to loop in the recordset i'm using adodc data control
-
Jul 8th, 2005, 06:48 AM
#2
Thread Starter
Lively Member
Re: birthdays!
i've tried this so far
not working though
Do Until Adodc.Recordset.EOF
If Adodc.Recordset.Fields("BirthDay") = Format(Now, "mm/dd/yyyy") Then
MsgBox "Today is " & Adodc.Recordset.Fields("First_Name") & "BirthDay!!!!", , "Birthdays"
End If
Loop
-
Jul 8th, 2005, 07:02 AM
#3
Re: birthdays!
Is Birthday a date/time field?
In what format are dates stored in this field?
-
Jul 8th, 2005, 07:04 AM
#4
PowerPoster
Re: birthdays!
I would do this:
set rs = new adodb.recordset
sql = " SELECT [FIRST NAME] FROM TABLENAME WHERE [BIRTHDATE] = " & "'" & CDATE(DATE) & "'"
rs.Open SQL,CnxnTechSQL, adOpenKeyset, adLockReadOnly, adCmdText
if not rs.bof and not rs.eof then
rs.movefirst
msg = ""
do
msg= msg & "Happy Birthday " & rs![[First Name] & "" & vbcrlf
rs.movenext
loop while not rs.eof
msgbox, msg
rs.close
set rs = nothing
-
Jul 8th, 2005, 07:30 AM
#5
Thread Starter
Lively Member
Re: birthdays!
i'm getting an error on this line
rs.Open SQL, CnxnTechSQL, adOpenKeyset, adLockReadOnly, adCmdText
what does htis do CnxnTechSQL?
anyway the error is
Runtime error 3001
Arguments are of the wrong type ,are out of acceptable range,or are in conflict with one another
-
Jul 8th, 2005, 07:36 AM
#6
PowerPoster
Re: birthdays!
cnxntechsql is the database connection name
-
Jul 8th, 2005, 07:37 AM
#7
Re: birthdays!
CnxnTechSQL appears to be a connection object.
To properly define it as such, you would do
VB Code:
Dim CnxnTechSQL As ADODB.Connection
Set CnxnTechSQL = ADODB.Connection
Then, you would give the connection object a connection string to your database.
-
Jul 8th, 2005, 08:28 AM
#8
Re: birthdays!
VB Code:
Dim recordbday() as string
Dim todaydate() as string
Do Until Adodc.Recordset.EOF
recordbday = Split(adodc.recordset.fields("Birthday"),"/")
todaydate = Split(now,"/")
If recordbday(0) & "/" & recordbday(1) = todaydate(0) & "/" & todaydate(1) Then
MsgBox "Today is " & Adodc.Recordset.Fields("First_Name") & "BirthDay!!!!", , "Birthdays"
End If
Loop
try that..although I didn't test it
-
Jul 8th, 2005, 08:36 PM
#9
Re: birthdays!
This might work also...
VB Code:
Do Until Adodc.Recordset.EOF
If DateValue(Adodc.Recordset.Fields("BirthDay")) = DateValue(Date) Then
MsgBox "Today is " & Adodc.Recordset.Fields("First_Name") & "BirthDay!!!!", , "Birthdays"
End If
Loop
And this too...
VB Code:
SQL = " SELECT [FIRST NAME] FROM TABLENAME WHERE [BIRTHDATE] = " & "'" & DateValue(Date) & "'"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|