Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2006

Tip: Looking for answers? Try searching our database.

Updating a table then deleting current record

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill - 17 Jan 2006 22:06 GMT
Good afternoon all,
I have a dB that I am working on that a user can submit a request to add
something to a table that is used as a record source.  Once the user hits
submit, it sends out an email to a group mail box to tell managers what has
been requested and also puts the information in a temp table (tbl_TEMP).  The
manager can then go into the dB and access the manager area, in there, there
is a form which prompts them for the MainID.  After the manager enters that
it runs a query and pulls that information from the temp table.  From here
the manager needs to be able to accept the change or deny it.  I am having
issues with the Accept feature.  Since there is quite a few tables that it
could possibly need to get appended to I have gone with the following script
to do the append if there is information in the field of temp table.

Function Accept()
'Servicing Standards
If "tbl_TEMP.Servcngstndrds" <> "" Then
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tbl_ServStand ( ServStand ) SELECT tbl_TEMP.
Servcngstndrds FROM tbl_TEMP"
End If    
End Function

(I have this for every field of the temp table that goes to all different
tables)

This is making it want to append ALL the information from the temp tables
field and not just from the current record that was pulled up which is what I
need.  I need as well, that after the information from the current record is
appended it needs to get deleted out of the temp table.

My current way of doing it is with a macro that turns SetWarning off, runs
the code, then runs a delete query (which it never seems to get to), then
turns back on the warnings.

Thanks in advance
Bill
Alex Dybenko - 18 Jan 2006 06:37 GMT
Hi Bill,
instead of
If "tbl_TEMP.Servcngstndrds" <> "" Then
you have to write something like this:

If len(dfirst("Servcngstndrds","tbl_TEMP") & "")>0 Then

Signature

Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Good afternoon all,
> I have a dB that I am working on that a user can submit a request to add
[quoted text clipped - 39 lines]
> Thanks in advance
> Bill
Bill - 18 Jan 2006 14:04 GMT
Thanks a lot Alex...
I feel I am getting much closer but I am not quite there yet.  When I run it
now it still appends all the temp information from the table and not just the
current record.. After it appends it deletes everything out of the table not
just the current record.  How do I go about telling it to just affect the
current record.  Thanks.

Bill
Alex Dybenko - 19 Jan 2006 05:19 GMT
Hi Bill,
in this case you have to filter temp table by current record, for example:

DoCmd.RunSQL "INSERT INTO tbl_ServStand ( ServStand ) SELECT
tbl_TEMP.Servcngstndrds FROM tbl_TEMP Where tbl_TEMP.<SomeID>=" &
me.<SomeID>

where <SomeID> - is a unique field, which identifies current record

Signature

Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Thanks a lot Alex...
> I feel I am getting much closer but I am not quite there yet.  When I run
[quoted text clipped - 7 lines]
>
> Bill
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.