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

Duplicates based on date

266 256MB
I have a form to schedule appointments. We schedule what we call a "first am" and a "first pm" appointment for each day. I have these two options displayed as check boxes on my form. They are yes/no fields in the underlying table. I would like when the user checks either one of them, for the database to look at the date that has been entered in my date field and make sure that there isnt another first am or pm already checked for that day. As we can only have one of each per day. Is something like this possible? thanks
Jan 9 '13 #1
15 1902
Seth Schrock
2,965 Expert 2GB
It is totally possible. The check would consist of a DCount() where you search your table for all records where the date equals the selected date and first am or pm is true. If it equals more than 0 then it is already scheduled.

There are a couple of ways to implement this. You could check when the first AM box is checked and automatically uncheck it if that spot is already filled. You could also use the date field's After_Update event to run the DCount() and disable the checkbox if the DCount() returns anything. This would make it so that you would know if the spot is taken as soon as you select the date. If you want to do the later option, then I would use an If/Then statement to make sure the update to the date field wasn't to remove the date as trying to run the DCount() without the date being populated would cause an error. Something like
Expand|Select|Wrap|Line Numbers
  1. If Not IsNull(Date_Field Then
  2.      DCount(Fill_this_in)
  3. End If
Jan 9 '13 #2
didacticone
266 256MB
I am using the following and it is returning the following message "run time error '3464': data type mismatch in criteria expression". the date field is set as a date/time field in the table.

Expand|Select|Wrap|Line Numbers
  1. If DCount("*", "blank work order table", "[FIRSTAM]=" & Me![firstam] & " And [DATE1] = '" & _
  2.                                      Me![Date1] & "'") > 0 Then
  3.  
  4.      MsgBox "ALREADY A FIRST CALL FOR THIS DAY"
Jan 9 '13 #3
Seth Schrock
2,965 Expert 2GB
I believe that you would need to change your criteria to
Expand|Select|Wrap|Line Numbers
  1. "[FIRSTAM]= True And [DATE1] = '" & Me![Date1] & "'"
I don't have a database to test this on and I'm not sure if the "True" needs to go inside the quotes or outside, but I don't think that you will get a mismatch error.
Jan 9 '13 #4
didacticone
266 256MB
still getting the same error unfortunately
Jan 9 '13 #5
Seth Schrock
2,965 Expert 2GB
Try creating a query and first just test for FIRSTAM = True. If that works, then remove that criteria and replace it with the DATE1 = full form reference. Let me know which one fails so that I can know which one is causing the error.
Jan 9 '13 #6
didacticone
266 256MB
i made a query and set the criteria as true and that returned results. im not totally sure what you mean by " date1 = full form reference"
Jan 9 '13 #7
didacticone
266 256MB
i actually just changed the date portion of the code and used street instead and that worked... the street field is just a text field... so it seems as though the problem is the date portion of the code
Jan 9 '13 #8
Seth Schrock
2,965 Expert 2GB
Oh duh, you need to remove the single quotes like this:

Expand|Select|Wrap|Line Numbers
  1. If DCount("*", "blank work order table", "[FIRSTAM]= True And [DATE1] = " & Me![Date1]) > 0 Then
  2.  
The single quotes are making the Me!Date1 be passed as a string instead of a date. I must be slipping :)
Jan 9 '13 #9
didacticone
266 256MB
i just used your latest code and its not returning an error but its also not picking up the duplicate and returning my message box... its just not doing anything
Jan 9 '13 #10
Seth Schrock
2,965 Expert 2GB
What event is triggering this code?
Jan 9 '13 #11
didacticone
266 256MB
i have it in the afterupdate of the firstpm check box
Jan 9 '13 #12
didacticone
266 256MB
i meant firstam checkbox sorry
Jan 9 '13 #13
didacticone
266 256MB
i actually got it to work using the following

Expand|Select|Wrap|Line Numbers
  1. If DCount("*", "blank work order table", "[FIRSTPM]= True And [date1] = #" & Me.Date1 & "#") > 0 Then
thanks for your help!
Jan 9 '13 #14
Seth Schrock
2,965 Expert 2GB
No problem. I suppose I should have known, but I didn't think that the # sign was necessary unless you where typing in the actual value.
Jan 9 '13 #15
NeoPa
32,556 Expert Mod 16PB
It is absolutely necessary. In fact, there is more required if you want your databases to work outside of the USA - Literal DateTimes and Their Delimiters (#).

Your DCount() reference should look like :
Expand|Select|Wrap|Line Numbers
  1. DCount("*", "blank work order table", "[FIRSTPM] And ([date1] = #" & Format(Me.Date1, "m\/d\/yyyy") & "#)")
Jan 10 '13 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: M.Stanley | last post by:
Hi, I have a problem..I'm doing a specific query where I'm joining fields from a table with appednded data (there are duplicate records, except for the date/time), and another query. I want the...
2
by: Anton ml. Vahčič | last post by:
Hi, Can somebody tell me how I get local time (user's browser time - not server time)? Which function do I call in c# asp.net? Anton, ml.
67
by: PC Datasheet | last post by:
Transaction data is given with date ranges: Beginning End 4/1/06 4/4/06 4/7/06 4/11/06 4/14/06 4/17/06 4/18/06 4/21/06 426/06 ...
20
by: keri | last post by:
Hi, I am creating a table where I want to use the date as the primary key - and to automatically create a record for each working date (eg Mon to Fri) until 30 June 2007. Is this possible? I do...
4
by: ScarletPimpernal | last post by:
Hi Friends, I have a table with field Id--vDate ------------- 1--3/1/2007 12:00:00 AM 2--4/1/2007 12:00:00 AM 3--4/12/2007 5:28:15 PM 4--3/1/2005 12:00:00 AM
4
by: mcca0081 | last post by:
hi - i'm trying to delete one of the duplicate records based on the most current date. here's the code for my access 2000 db. any help would be appreciated!!! - thank you kindly Sub...
3
by: metsu962 | last post by:
Okay so I've been tearing my hair out for weeks over this issue. What I have is a Crystal Report that's showing a table pulled from an Access Database. The database is a HUGE pile of junk and it...
3
by: Vinda | last post by:
Hi Bytes, Using a previous question as a base Access 2000 Inserting multiple rows based on a date range. I also wanted to insert multiple rows into a table according to a date range supplied by a...
12
bard777
by: bard777 | last post by:
I fully expect to have a duh moment when I read replies to this....BUT.... I have a table with duplicates in the field (could be 2 records with same value, might be 7 records). I need to delete...
1
by: maydie | last post by:
I have 3 tables with the following relevant fields: ItemsFrmManufacturer Date......SerialNum.....Description.....Status 01012010..000001..... Item1..... IN...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.