I want to apply Conditional Fomatting to a sub form's date control when it's of earlier date than a date in another table (form). I use following code in Expression is: DateDiff("s",DL ookUp("[LastMeeting]","LastMeetingD ate"),[DateOfInfoAdded])>0
but keep getting a syntax error message. Any idea what I'm doing wrong?
20 2077 ADezii 8,834
Recognized Expert Expert
I want to apply Conditional Fomatting to a sub form's date control when it's of earlier date than a date in another table (form). I use following code in Expression is: DateDiff("s",DL ookUp("[LastMeeting]","LastMeetingD ate"),[DateOfInfoAdded])>0
but keep getting a syntax error message. Any idea what I'm doing wrong?
Your syntax, is in fact, incorrect. Try: -
DCount("[LastMeeting]", "LastMeetingDate", "[DateOfInfoAdded] < =#" & "Forms!frmFormName![Date Field] & "#") > 0
-
Your syntax, is in fact, incorrect. Try: -
DCount("[LastMeeting]", "LastMeetingDate", "[DateOfInfoAdded] < =#" & "Forms!frmFormName![Date Field] & "#") > 0
-
I typed in
DCount("[LastMeeting]", "LastMeetingDat e", "[DateOfInfoAdded] < =#" & "Forms!Compound Observations![DateOfInfoAdded] & "#") > 0
but still keep getting the syntax error message. Some more info:
The main form is called Compounds and contains 2 subforms:
LastMeeting (Form view) with a date control called LastMeetingDate and
CompoundObserva tions (Datasheet view) with a date control called DateOfInfoAdded .
I want the text of the DateofInfoAdded control become red when it's later than LastMeetingDate . For this I want to use the Conditional Formatting tool on the DateOfInfoAdded control. And it should work immediately after update of either dates.
nico5038 3,080
Recognized Expert Specialist
The " on the second line needs to be removed.:
DCount("[LastMeeting]", "LastMeetingDat e", "[DateOfInfoAdded] < =#" & Forms!CompoundO bservations![DateOfInfoAdded] & "#") > 0
Also be sure that your application works on a computer with the US regional settings. Having a default computer date format of dd-mm-yyyy will cause trouble...
Nic;o)
The " on the second line needs to be removed.:
DCount("[LastMeeting]", "LastMeetingDat e", "[DateOfInfoAdded] < =#" & Forms!CompoundO bservations![DateOfInfoAdded] & "#") > 0
Also be sure that your application works on a computer with the US regional settings. Having a default computer date format of dd-mm-yyyy will cause trouble...
Nic;o)
Ok, getting there. I changed the setting to US and took out that ". Now I don't get the syntax error. But it doesn't change the color either.
nico5038 3,080
Recognized Expert Specialist
Hmm, could be because of a "not found" that will return Null as value for the DCOUNT(), try adding the NZ() function like:
NZ(DCount("[LastMeeting]", "LastMeetingDat e", "[DateOfInfoAdded] < =#" & Forms!CompoundO bservations![DateOfInfoAdded] & "#")) > 0
Nic;o)
ADezii 8,834
Recognized Expert Expert
I typed in
DCount("[LastMeeting]", "LastMeetingDat e", "[DateOfInfoAdded] < =#" & "Forms!Compound Observations![DateOfInfoAdded] & "#") > 0
but still keep getting the syntax error message. Some more info:
The main form is called Compounds and contains 2 subforms:
LastMeeting (Form view) with a date control called LastMeetingDate and
CompoundObserva tions (Datasheet view) with a date control called DateOfInfoAdded .
I want the text of the DateofInfoAdded control become red when it's later than LastMeetingDate . For this I want to use the Conditional Formatting tool on the DateOfInfoAdded control. And it should work immediately after update of either dates.
In the AfterUpdate() Event of the [DateOfInfoAdded] Field on the CompoundObserva tions SubForm, place the following code. Similar, but different, code would also be placed in the [LastMeetingDate] Field on the LastMeeting Sub-Form: - Private Sub DateOfInfoAdded_AfterUpdate()
-
If Not IsNull(Me![DateOfInfoAdded]) And Not IsNull(Forms!Compounds!LastMeeting.Form![LastMeetingDate]) Then
-
If CDate(Me![DateOfInfoAdded]) > CDate(Forms!Compounds!LastMeeting.Form![LastMeetingDate]) Then
-
Me![DateOfInfoAdded].ForeColor = vbRed
-
Else
-
Me![DateOfInfoAdded].ForeColor = vbBlack
-
End If
-
End If
-
End Sub
In the AfterUpdate() Event of the [DateOfInfoAdded] Field on the CompoundObserva tions SubForm, place the following code. Similar, but different, code would also be placed in the [LastMeetingDate] Field on the LastMeeting Sub-Form: - Private Sub DateOfInfoAdded_AfterUpdate()
-
If Not IsNull(Me![DateOfInfoAdded]) And Not IsNull(Forms!Compounds!LastMeeting.Form![LastMeetingDate]) Then
-
If CDate(Me![DateOfInfoAdded]) > CDate(Forms!Compounds!LastMeeting.Form![LastMeetingDate]) Then
-
Me![DateOfInfoAdded].ForeColor = vbRed
-
Else
-
Me![DateOfInfoAdded].ForeColor = vbBlack
-
End If
-
End If
-
End Sub
I added the code and yes, the dates turn red BUT only in Continious Form mode (I guess I have to live with that) AND all the dates change color. Also the once that are supposed to remain black because they are of earlier than the LastMeetingDate date.
I added the code and yes, the dates turn red BUT only in Continious Form mode (I guess I have to live with that) AND all the dates change color. Also the once that are supposed to remain black because they are of earlier than the LastMeetingDate date.
It's amazing what a challenge this is. In another discussion posted earlier no solution was found. It seems to easy actually. Have the date control of one subform change colour depending on a date control on another subform.
ADezii 8,834
Recognized Expert Expert
I added the code and yes, the dates turn red BUT only in Continious Form mode (I guess I have to live with that) AND all the dates change color. Also the once that are supposed to remain black because they are of earlier than the LastMeetingDate date.
I added the code and yes, the dates turn red BUT only in Continious Form mode (I guess I have to live with that) AND all the dates change color. Also the once that are supposed to remain black because they are of earlier than the LastMeetingDate date.
Glad you were successful, but it should work equally well on a Single as opposed to Continuous Form View.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jouke Langhout |
last post by:
Hello all!
For quite some time now, I've got the following problem:
Access won't close properly when a user closes the application. An
ACCESS process stays active and that process can only be terminated by
pressing ++ and then terminate the process.
I searched the entire internet and found out that there could be two
things wrong (both of them are mentioned in the bug list on the access
|
by: Dimitri Furman |
last post by:
Given:
Access 2002/2003
A subform in datasheet or continuous view, placed on a tab page (this last
may or may not matter)
Conditional formatting applied to some controls on the subform -
format expressions are the same for all controls
Under some undetermined circumstances, when such subform is displayed, the
controls on the subform start to visibly flicker, the cursor in the subform
stops blinking, and CPU utilization goes to 100%....
|
by: Von Bailey |
last post by:
I have a form where the conditional formatting is set on some fields
to bold if certain conditions are met. However, when the conditions
are met some of the data that is to bold is either not showing or only
part of the data in the field displays (i.e. it will display the last
name but not the first name or it will display neither).
When the conditional formatting is removed it displays all the data as
it should be display so the data...
|
by: Andrew Chanter |
last post by:
Does anyone know a way you can use conditional formatting to create a banded
style view as is commonly seen on the internet. (In othe words the first
record appears on a gray background, the 2nd on white, the third on gray etc
etc.) I could write an expression based on the odd/even status of the
primary key but this wont work when sorting and filtering is applied.
Any suggestions gratefully received.
|
by: John Marble |
last post by:
I am quite new with Access, so please be indulgent if my question
sound a little bit newbish.
I have two table in the same database: DOSSIER and MAIN.
MAIN is having already formatted data that I need to import in
DOSSIER, so everything is ready.
I used help to determine the correct synthax to do this with SQL but
it keeps saying that my synthax is wrong, here are my lines:
| |
by: GGerard |
last post by:
Hello
Is there a way to use a variable in the Conditional Formatting of a Textbox?
Example :
I want the background of a textbox in a continuous form to change color when
the value of "MyField1" is True.
No problem, I just need to write "Expression is" and " = -1 "
|
by: Typehigh |
last post by:
I have many text fields with conditional formatting applied,
specifically when the condition is "Field Has Focus". Without any
events associated with the fields the conditional formatting works
perfectly. However, I have code that runs under the ON CLICK event. The
code changes the focus to other controls, which means the conditional
formatting is no longer displayed. This part makes sense to me.
Here's what doesn't make sense. The last...
|
by: midlothian |
last post by:
Hello,
I have conditional formatting set up on a subform based on a calculated
value in the underlying query. For instance, if Sales are >$1000, the
query displays "Yes," otherwise it displays "No." The conditional
formatting is set up to read the 'Yes' or 'No' value and color the text
accordingly.
I have an event in the subform that allows users to update the sales.
It actually runs an update query behind the scenes. What I want to...
|
by: Filips Benoit |
last post by:
Dear All,
Access 2003 adp on SQL_server 2005
A continious form showing 1 month based on table 'CALENDAR_MONTH_GRID' and
fill with a SP.
Fields: Companyname, Day1, day2, etc.
The value in the day-fields is like WK (weekend), NH (National holiday),
etc.
Depending on the fieldvalue the field is colored using conditional
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |