I am trying to restrict the user to only enter date which is weekdays. so, it shouldn't allow a date that is weekend such as 08/04/07 (Sunday). Can someone help me with this issue. In short i want the user to enter a date which is Monday, Tuesday, Wednesday, thursday and Friday!
Additionally, i'm new to Databases so, could you tell me whether the validation rule given should be used during table design or on the form date field. Any help would be much appreciated.
8 4698
ok, assuming this all done via a form
say u had a field called txtDate, this is where the user enters a date
each control have a number of event handlers, kinda like triggers in oracle
in access, txtboxes have a beforeupdate event handler, this allows u to validate and abort the update
to get the weekday, u can use the WeekDay function
so for example -
private sub txtDate_BeforeUpdate(Cancel as Integer)
-
-
Dim iWeekNo as integer
-
-
iWeekNo = WeekDay(txtDate)
-
if iWeekNo = 1 or iWeekNo = 7 then '1=sunday,7=saturday
-
cancel = true 'set to true to abort update
-
msgbox "Please enter mon-fri date"
-
end if
-
end sub
-
It's you again! again u've sorted the problem, ur awesum a natural genueis u r! this was probably a piece of cake for u.
another thing i wanted to know is, how to automatically open a form based on a selected value in a combo box. In short, if da user selects 'Contact Parent' then i want it to automatically open another form.
Once again thanks for helping me out.
Hello again, happy to help out
Regarding your other question, u need to make use of the event handler called AfterUpdate. This is called each time a change is made
eg u have a combobox called cboMyCombo (it could be a textbox also, doesnt matter)
private sub cboMyCombo_AfterUpdate()
if Me.cboMyCombo = "Contact Parent" then
DoCmd.OpenForm "new form"
end if
end sub
Hello again, happy to help out
Regarding your other question, u need to make use of the event handler called AfterUpdate. This is called each time a change is made
eg u have a combobox called cboMyCombo (it could be a textbox also, doesnt matter)
private sub cboMyCombo_AfterUpdate()
if Me.cboMyCombo = "Contact Parent" then
DoCmd.OpenForm "new form"
end if
end sub
I tried using this code but nothing seems to happen.it doesn't even display any error message! the name of the combo box is cmbAction and i even tried using this code: Private Sub cmbAction_AfterUpdate()
If Me.cmbAction = "Contact Parents" Then
DoCmd.OpenForm "frmSendEmail", acNormal, acFormEdit, acWindowNormal
End If
End Sub
In addition to this, for the same combo box i want the command button named cmdPrintDetentionSlip to be visible if the value Detention is selected.
Hope u can make my day today as well!
How many columns do u have in your combo?
try this to see what is selected
Private Sub cmbAction_AfterUpdate()
msgbox "Selected is >" & Me.cmbAction & "<"
If Me.cmbAction = "Contact Parents" Then
DoCmd.OpenForm "frmSendEmail", acNormal, acFormEdit, acWindowNormal
End If
End Sub
when u run it, what is displayed in the message box
How many columns do u have in your combo?
try this to see what is selected
Private Sub cmbAction_AfterUpdate()
msgbox "Selected is >" & Me.cmbAction & "<"
If Me.cmbAction = "Contact Parents" Then
DoCmd.OpenForm "frmSendEmail", acNormal, acFormEdit, acWindowNormal
End If
End Sub
when u run it, what is displayed in the message box
The message displayed is Selected is >4<
this means that u are using multiple columns in your combo
what is the sql for the combo
if the description is the 2nd field in the combo, then try this
if cmbAction.Column(1) = "Contact Parents" then
cmbAction.Column(0) refers to first column, in this case, most likely 4
cmbAction.Column(1) refers to second column
cmbAction.Column(2) refers to third column etc
eg
select f1, f2, f3
from mytable
column(0) = f1
column(1) = f2
etc
Assuming its the 2nd column -
Private Sub cmbAction_AfterUpdate()
-
-
cmdPrintDetentionSlip.Visible = False
-
If Me.cmbAction.Column(1) = "Contact Parents" Then
-
DoCmd.OpenForm "frmSendEmail", acNormal, acFormEdit, acWindowNormal
-
Elseif Me.cmbAction.Column(1) = "Detention" then
-
cmdPrintDetentionSlip.Visible = True
-
End If
-
-
End Sub
-
Normal practice, its not good to use hardcoding of description names as they are subject to change, better to check against the numbers
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tiernan |
last post by:
Hi all
I'm looking for a way to find the number of weekdays between 2 dates
In my form I have three fields for a begin date (dd)(mm)(yyyy) and
three for the end date (dd)(mm)(yyyy)
Now these...
|
by: elaines |
last post by:
I can't seem to get this to work. Any help appreciated. The alert
message always comes up.
Here is my code
<SCRIPT type="text/javascript">
function fte()
{
var hours =...
|
by: Ash |
last post by:
Hi everyone,
This problem has been puzzling me for a fair time now, and has severely
frustrated me!! Perhaps I'm just not getting the syntax right, but the
problem is rather simple...
Take a...
|
by: Matt Mercer |
last post by:
Hi,
My first post here. I am a self-taught, very "green" web developer. It
is not the main focus of my job but required from time to time.
I am developing a web application that logs security...
|
by: M |
last post by:
Hi,
it's possible to append a custom action
to a client-side verification of a validation control ?
I have a validator summary control that shows
(automatically) a message box if the validation...
|
by: Sun Jian |
last post by:
Hi,
I am trying to customize the asp.net validation to achieve the following:
Upon submitting the form, client side validation will run, and it will stop
at the first error detected. For...
|
by: serge calderara |
last post by:
Dear all,
I have read that ASP.NET does double user input validation of control when
they are place on the page. Once on teh client side and again from server
side right ?
Could explain how...
|
by: MLH |
last post by:
I'm thinking of an integer field in which I could write values up to
1+2+4+8+16+32+64 and to use these values later. Each of the
individual values would represent a weekday from Sunday to Saturday....
|
by: sharsy |
last post by:
Hi guys,
I would like to setup a validation rule for a database in microsoft
access that restricts data entry so that a certain field can only be
filled in if another field has a specific answer...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |