473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Setting date condition

DL
Hi,
I have a table with quite a few fields wich saves al kind of activities on
has done on one day.
Most important to identify a unique record is the date and personID.
A person is only allowed to enter his activity data once per date.
Now I have to set a condition that will check that a person is not entering
his activity data twice for that day.

I already have tried a lot in macro's , conditions and VB.
Here are some examples:

IsNull DLookUp([activityTable]![datefield]; [activityTable];
[activityTable]![datefield]=[datefieldInForm])
set in a macro as a condition, so that if there is no record with the
current date it will give Null and thus make the expression True and
excecuting my following command.

or

Set dbs = CurrentDb
SQL_Str = "SELECT datefield FROM activityTable WHERE datefield
=[datefieldInForm]
Set t_Recordset = dbs.OpenRecordset(SQL_Str)
If t_Recordset!Code Then already_there= "yes"

If a record did exist with the given date then de IF statement should be
True and thus setting already_there to "yes".

Somehow all these thing keep on giving errors. I'm probably overlooking
something really easy but I'm just stuk on this one.

Please help....
Nov 13 '05 #1
1 3315
On Wed, 30 Jun 2004 01:07:26 +0200, "DL" <da*******@hotmail.com>
wrote:
Hi,
I have a table with quite a few fields wich saves al kind of activities on
has done on one day.
Most important to identify a unique record is the date and personID.
A person is only allowed to enter his activity data once per date.
Now I have to set a condition that will check that a person is not entering
his activity data twice for that day.

I already have tried a lot in macro's , conditions and VB.
Here are some examples:

IsNull DLookUp([activityTable]![datefield]; [activityTable];
[activityTable]![datefield]=[datefieldInForm])
set in a macro as a condition, so that if there is no record with the
current date it will give Null and thus make the expression True and
excecuting my following command.

or

Set dbs = CurrentDb
SQL_Str = "SELECT datefield FROM activityTable WHERE datefield
=[datefieldInForm]
Set t_Recordset = dbs.OpenRecordset(SQL_Str)
If t_Recordset!Code Then already_there= "yes"

If a record did exist with the given date then de IF statement should be
True and thus setting already_there to "yes".

Somehow all these thing keep on giving errors. I'm probably overlooking
something really easy but I'm just stuk on this one.

Please help....

In query expressions (including domain aggregate functions) you need
to surround the dates with #'s. So try it like ...

SQL_Str = "SELECT datefield FROM activityTable WHERE datefield
= #" & [datefieldInForm] & "#"
DLookUp("datefield", "activityTable", "datefield=#" &
[datefieldInForm] & "#")

- Jim
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Luke Wright | last post by:
Hi, I have built a setup project to install an application I am developing. I would like to be able to prompt the user whether to install Shortcuts in the following locations: * Start Menu *...
14
by: Toby | last post by:
I've a DataAdapter with: SELECT ID, Employee, , Period_End_Date, Job, Description, Exported, Units, Cost_Code, Category, Class, Chargeout_Level, PayID, Rate FROM tblTimeEntry WHERE ...
4
by: Harsha Shah | last post by:
Hello, I have an application that requires specific date format on user's system, so they have to do the setting throgh control panel-> regional setting -> customise -> date -> short format ->...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
4
by: Rodger Dusatko | last post by:
In VB .NET I am having problems setting breaks. I want the break to be independant of any single function: for example: err.number or global variables When I try to set a break with the 'Data'...
5
by: Amogh | last post by:
Hi, My question is related to setting freed pointers to NULL. After freeing a pointer: 1) Should the freeing routine also be responsible for setting the pointer to null? 2) Or, should the...
2
by: archana | last post by:
Hi all, I am facing some wired problem while using above mention data type. What i am doing is i am writing DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" +...
5
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I have a solution with 50 projects. They are all compiled in DEBUG mode and the output path has been modified to a custom directory I now want to build RELEASE mode and the Output Path...
1
by: sidathkp | last post by:
Here is a sample of the xml file that I have: <provider> <cinames> <cinema> <id>1111</id> <name>ABC cinema</name> <address>123 street</address>...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.