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

Problems with Before Update and Locked Controls

Having tried various permutations of Before Update and well for that
matter, After Update, OnExit, OnEnter, etc. and also Locked controls,
I'm still unable to obtain the intended results. There are actually two
parts of what I'm trying to accomplish, but are interrelated. When one
part performs as it should, then upon implementation of the other,
conflicts arise and vice versa.

A form (frmEvents) is used to logged various events and one of the
controls is (EventDate) that is used when setting up the data. There
are two elements of the Event Date control that require code to prevent
inadvertent problems. One element is to disallow setting up a future
event with an EventDate that has the same date as a previous one. So on
the form's BeforeUpdate, I used the following code:

Private Sub Form_BeforeUpdate(Cancel As Integer)

If Me!EventDate = DLookup("[EventDate]", "tblEvent", "EventDate = #
" & Me![EventDate] & "#") Then
MsgBox "Sorry, the event date that you have typed has already been
used. Please enter another date."
Me!EventDate.SetFocus
Cancel = True
RunCommand acCmdUndo
End If

End Sub

Well, this works, sort of, but it of course undoes all of the record
data entered (and sometimes it does not even recognize a previous date
used - strange). However, because if it is used on the control's
BeforeUpdate, then it conflicts with the second element noted below.

The second element is to prevent a user from changing an EventDate if
it is earlier than the current Date (because all data for the event has
been entered, recorded, finalized, etc.) and changing the date would
cause potential problems. I have approached this two different ways.
One using Before Update and the other using Locked record. The Locked
record code seems to work best, but it conflicts with part one's code
above. The examples are:

Private Sub EventDate_Enter()

If Me!EventDate > Date Then
If IsNull(Me!EventDate) Then
Exit Sub
Else
Me!EventDate.Locked = True
End If
End If

End Sub

Plus:

Private Sub EventDate_KeyDown(KeyCode As Integer, Shift As Integer)

If Me!EventDate < Date Then
MsgBox "Be advised that since the event has already occurred the
Event Date cannot be changed."
End If

End Sub
The other code used:

Private Sub EventDate_BeforeUpdate(Cancel As Integer)

If Me!EventDate < Date Then
MsgBox "The Event Date cannot be changed at this point because the
event event has already occurred."
Cancel = True
RunCommand acCmdUndo
End If

End Sub
Other perplexing problem is that I'm using a Long Date for the control,
but acCmdUndo does not always restore the day (i.e. Tuesday) before the
date and then there is the ensuing error message that the value entered
isn't valid for the field. At least for part one, acCmdUndo is
necessary because the user may not know what the original date was
before typing in a different one.

So need help, any assistance or suggestions will be much appreciated.
Thanks, Rolan

Nov 13 '05 #1
1 2101
rkc
Rolan wrote:
Having tried various permutations of Before Update and well for that
matter, After Update, OnExit, OnEnter, etc. and also Locked controls,
I'm still unable to obtain the intended results. There are actually two
parts of what I'm trying to accomplish, but are interrelated. When one
part performs as it should, then upon implementation of the other,
conflicts arise and vice versa.


<snip long explanation of problem>

Use the forms Current event to check whether or not the EventDate has
occurred. Lock the EventDate control if it has.

Use Me!EventDate.Undo in the form's BeforeUpdate event instead of
RunCommand acCmdUndo.
Nov 13 '05 #2

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

Similar topics

14
by: Jim Hubbard | last post by:
Are you up to speed on the difficulties in using the 1.1 .Net framework? Not if you are unaware of the 1,596 issues listed at KBAlertz (http://www.kbalertz.com/technology_3.aspx). If you are...
3
by: David W. Fenton | last post by:
A very old app of mine that's been in production use, and largely unchanged since about 1998 has started recently throwing error 3188 (can't update, locked by another session on this machine) when...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
2
by: Tomas Vera | last post by:
Hello All, I'm having problems creating a page with dynamic checkboxes in a WebApp. In my app, I need to query a database, then (based on results) add checkboxes to my form and set their...
3
by: Rick | last post by:
I have an interesting problem when I run the following code in Netscape (7.02) vs. IE. This page works great in IE and all my controls bring up the validation summary dialog box if the required...
21
by: matvdl | last post by:
I have a system that was originally developed in asp - the pages are saved in SQL (there are over 10,000 pages) and saved to a temp directory in the server when requested by a client. I have...
3
by: ibiza | last post by:
Hi all, I am currently developing in asp.net 2.0 and I was at first impressed with the numerous login and user controls they provided to ease the task of managing users. But I am starting to...
9
bhcob1
by: bhcob1 | last post by:
Hey guys, 'Update or CancelUpdate without AddNew or Edit' On my database i keep occasionly get this error when i try and edit a field, it is not everytime. It will be working fine and then this...
3
by: k2storm | last post by:
I'm having problems with Reports and I'm seeking some help, or advice on how to solve this problem. Any help will be much appriciated! It’s hard to explain but I will try to do my best: In my...
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
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: 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
tracyyun
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...
0
agi2029
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.