473,396 Members | 2,151 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.

Recording locations of an object.

I have an Access 97 database to record the current location and status
of files in our office.
Each file has a record one field of which is it's current location.
On the form for each record is a 'limit to list' combobox from which
the user can update the file's current location.
I would like to be able to record the history of where a file has
been, so to do this I set up a second table linked to the first one by
a one to many relationship. I then coded the afterupdate event of the
bound combobox to run an INSERT INTO action query when the combobox is
changed.
This works just fine apart from the very first time the location is
selected ie when the contents of the combobox go from NULL to a
selected value the afterupdate event (of the control) does not seem to
be triggered. Hence the first selected location is not recorded and
the file's location history is incomplete.
Can anybody suggest why the afterupdate event is not being triggered
or how to get around this?
Your help would be very much appreciated.

Chris Thompson.
Nov 13 '05 #1
3 1291
You are using the AfterUpdate event of your combo to execute an Append query
statement to record its OldValue in another table.

If the combo initially had no value, the OldValue would be Null. You need to
specify the word "Null" in your append query statement to have the null
appended. Assuming the combo's bound column is numeric, use Nz() to assign
the word Null, as in the example below.

To get an error message if the query does not work correctly, use the
Execute method, with the dbFailOnError switch. You will end up with
something like this:
Private Sub Me.MyCombo_AfterUpdate()
Dim strSQL As String

strSQL = "INSERT INTO MyHistoryTable (SomeField) SELECT " &
Nz(Me.MyCombo, "Null") & " AS MyValue ...

dbEngine(0)(0).Execute strSQL, dbFailOnError
End Sub
Because you are using the combo's AfterUpdate event, the value gets written
even if the user undoes the record instead of saving it. If you wanted to
write the history only when the value really was changed, you would need to
save the OldValue of the combo into a variable in the BeforeUpdate event of
the *form*, and then in the form's AfterUpdate event, compare its value and
write the record if they are not the same.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Chris Thompson" <ch**************@ntlworld.com> wrote in message
news:35**************************@posting.google.c om...
I have an Access 97 database to record the current location and status
of files in our office.
Each file has a record one field of which is it's current location.
On the form for each record is a 'limit to list' combobox from which
the user can update the file's current location.
I would like to be able to record the history of where a file has
been, so to do this I set up a second table linked to the first one by
a one to many relationship. I then coded the afterupdate event of the
bound combobox to run an INSERT INTO action query when the combobox is
changed.
This works just fine apart from the very first time the location is
selected ie when the contents of the combobox go from NULL to a
selected value the afterupdate event (of the control) does not seem to
be triggered. Hence the first selected location is not recorded and
the file's location history is incomplete.
Can anybody suggest why the afterupdate event is not being triggered
or how to get around this?
Your help would be very much appreciated.

Chris Thompson.

Nov 13 '05 #2
Allen

Thank you very much for the courtesy of posting a reply.
I do not need to record the Old Value. All I want to do is record the
currently selected value so I assumed a query execute when the
afterupdate event was triggered would be fine and on all but the first
occasion it is. It is only on that very first selection (from NULL to
selected value) that this does not appear to happen. I have no need
to record the null value, only the subsequently selected values.
I have read some articles in this forum that suggest to me that
executing an action query in an afterupdate event might be a bit of a
no no, so don't know if I'm breaking some sort of unwritten rule?
Thanks again for your time in replying and if you have any other
thoughts I'd be grateful.

Chris.
Nov 13 '05 #3
That's fine, Chris. If you just want to record the current value in another
(history) table, use the AfterUpdate event of the *form*, not that of the
combo. That way, the history record gets written only if the change is
saved, not if it is undone. No law against that.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Chris Thompson" <ch**************@ntlworld.com> wrote in message
news:35**************************@posting.google.c om...

Thank you very much for the courtesy of posting a reply.
I do not need to record the Old Value. All I want to do is record the
currently selected value so I assumed a query execute when the
afterupdate event was triggered would be fine and on all but the first
occasion it is. It is only on that very first selection (from NULL to
selected value) that this does not appear to happen. I have no need
to record the null value, only the subsequently selected values.
I have read some articles in this forum that suggest to me that
executing an action query in an afterupdate event might be a bit of a
no no, so don't know if I'm breaking some sort of unwritten rule?
Thanks again for your time in replying and if you have any other
thoughts I'd be grateful.

Chris.

Nov 13 '05 #4

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

Similar topics

1
by: Manfred Schwab | last post by:
Recording messages and print statements in a textfile during program execution. Is there a similar command to redirect errormessages or print statements into a standart asciifile during...
0
by: ajac | last post by:
In the windows xp system the sound recording system give us only 1 minute of recording time. I would like to get the "recording time Length " to the maximum. please let me know Urgently. ...
3
by: Jussi Rasku | last post by:
Hello, I'm working on a small web-script that would allow me to remotely setup recordings to my tv-tuner (on my linux box). The idea is simple, but I'm unsure how to accomplish it. The idea:...
6
by: Dovelet | last post by:
Hi all, I would like to write DOS program to change the MS Windows Sound Recording source. When I run it with the parameter, it will change the recording source as follow: C:\> abc.exe...
0
by: Mad Scientist | last post by:
Has anyone been able to play back a mono WAV while recording, and saving the results as a stereo WAV (left channel = first mono recording, right channel = new recording)? Any sample code would...
1
by: Sakharam Phapale | last post by:
Hi All, I am developing an application like sound recorder. While recording if there is a silence for more than given time (say 5 seconds), Recording should be paused.
0
by: The Woo | last post by:
After years of dreaming, finally have my Access db set up to dial a highlighted phone number at my office (AT&T Merlin system, no less). My question: are there folks here familiar with any good...
1
by: zhangzhi | last post by:
HI£º i have a big problem about audio recording. my boss wanna a application of audio monitor, and he wanna it will detect voice and start recording automatically, avoiding recording silences....
2
by: tiffxi | last post by:
I'm an ASP.NET newbie. I'm trying to write an audio-recording code in an ASP.Net page. I created a windows User Control that has the buttons and codes for this (it calls the winmm.dll in system32...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: List of autostart locations Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list all the autostart locations for windows? Ans: Here is...
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: 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
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
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
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
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,...

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.