473,386 Members | 1,673 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,386 software developers and data experts.

Check for a Date then do something....

In a small scheduling DB that I created, I had a list of dates. When
the user clicks on a Merge button, I need the system to look at the
list and see if a date exists if it does give a message.

For example...

me.txtDate = 12/01/03
user clicks merge, the db looks at tbl_Days if it finds it,
msgbox(Date already in system)

I have been messing with dlookup but just can't get it to work.
Nov 12 '05 #1
2 1586
On 9 Feb 2004 20:12:37 -0800, Josh Armstrong wrote:
In a small scheduling DB that I created, I had a list of dates. When
the user clicks on a Merge button, I need the system to look at the
list and see if a date exists if it does give a message.

For example...

me.txtDate = 12/01/03
user clicks merge, the db looks at tbl_Days if it finds it,
msgbox(Date already in system)

I have been messing with dlookup but just can't get it to work.
Does this syntax work for you?
In the Click event of that command button:
If DCount("*","YourTableName","[txtDate] = #" & Me!ControlName & "#") 0 then

MsgBox "This date is taken!"
'Do something here
Else
'Do something else here
End If

[ControlName] is the control on the form that has the date to be
searched for.
The above assumes [txtDate] is a Date Datatype field.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 12 '05 #2
Try this code:

Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Set Db = CurrentDB
Set Rst = Db.OpenRecordset("Tbl_Days")
Rst.FindFirst "[DateFieldNameInTable = #" & Me!TxtDate & "#"
If Not Rst.NoMatch Then
MsgBox "Date already in system"
<<Do whatever when date is already in system>>
End If
Rst.Close
Set Rst = Nothing
Set Db = Nothing
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Josh Armstrong" <jo***********@socal.rr.com> wrote in message
news:b6*************************@posting.google.co m...
In a small scheduling DB that I created, I had a list of dates. When
the user clicks on a Merge button, I need the system to look at the
list and see if a date exists if it does give a message.

For example...

me.txtDate = 12/01/03
user clicks merge, the db looks at tbl_Days if it finds it,
msgbox(Date already in system)

I have been messing with dlookup but just can't get it to work.

Nov 12 '05 #3

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

Similar topics

15
by: Dan S | last post by:
My application asks the user to enter in a date - in the mm/dd/yyyy format. Is there any quick and easy way to verify the date the user enters is formatted correctly? Right now I'm calling...
4
by: mbosco51 | last post by:
Hi. I am tring to setup an asp script that will do the following... If file date/time is within last 10 minutes then response.redirect to file else do something else end if The text file...
5
by: TN Bella | last post by:
Trying to check if an entry for an date is < 3 years to current date or > 30 days from current date. How can I do this in asp.net....? Do I need to use the customvalidation. Can anyone give me an...
2
by: Naga Kiran | last post by:
Hi I want to set expiration date for my web based application. for eg it has to be worked for 15 days from the date when it was installed. More over i dont want to use system date to check the...
4
by: Michael C# | last post by:
Given a DateTime variable, what's the best way to check "minor" status (i.e., less than age 18 years) based on today's date? I came up with this: Dim minor As Boolean = true 'dtDOB is a...
6
by: Mike Charney | last post by:
Is there a way to check a files date and time stamp from VBA in access. I have a need check a date stamp on a file that I am importing. Thanks in advance, Mike m charney at dunlap hospital...
44
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
3
by: Lester | last post by:
I'm driving myself crazy with a problem in trying to translate a query written for Access to that for SQL server. I would think that I would use a trigger, but am not sure how to set it up. We...
2
by: KMEscherich | last post by:
Microsoft Access 2003 Hi there, am stuck with something that I am not sure on how to get done. I am attempting to have 3 check boxes and have 3 date fields. I need to have each date field be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.