Hi,
Bare with me this is going to take some explaining and any help is much appreciated
I have a form that stores details of sessions which include start/end date start/end time these sessions are associated with a project so you will have ten sessions associated to a project for example within the form i also have a session type dropdown so there are several different types of sessions that the user can chose from... so the important fields are as follows
ProjID
StartDate
EndDate
StartTime
EndTime
SessTypeID
What i need to do is is sum the total number of hours of a session type with the project ID
I have a query which points to the ProjectID and the sessionTypeID see below -
SELECT T_ActiveSession.SessionID, T_ActiveSession.ProjID, T_ActiveSession.StartTime, T_ActiveSession.EndTime, T_ActiveSession.SessTypeID, DateDiff("n",[startdate]+[starttime],[enddate]+[endtime]-[break]-[downtime]) AS Expr1, T_ActiveSession.SessComplete, T_ActiveSession.Downtime, T_ActiveSession.Break, T_ActiveSession.StartDate, T_ActiveSession.EndDate
-
FROM T_ActiveSession
-
GROUP BY T_ActiveSession.SessionID, T_ActiveSession.ProjID, T_ActiveSession.StartTime, T_ActiveSession.EndTime, T_ActiveSession.SessTypeID, T_ActiveSession.SessComplete, T_ActiveSession.Downtime, T_ActiveSession.Break, T_ActiveSession.StartDate, T_ActiveSession.EndDate
-
HAVING (((T_ActiveSession.ProjID)=SubFormFieldValue("F_ClientDetails","SF_Session","ProjID")) AND ((T_ActiveSession.SessTypeID)=SubFormFieldValue("F_ClientDetails","SF_Session","sesstypeid")))
-
ORDER BY T_ActiveSession.SessTypeID;
-
I then run a recordset on that query which totals up the number of hours that have been completed for session type1 within project1 for example
so there could be 10 records for session type 1 on various different days and session lengths within project1
the recordset below totals the number of hours worked on a session type 1
and then writes that value to a table.
The problem i have is when a user goes back to a previously saved record and tries to change the session type from session type1 to session type2 for example it sums the total number of hours for session type2 i need to be able to subtract the hours from session type1 in the table
hope my ramblings make sense
regards Phill -
-
Dim dbsCurrent As Database
-
Dim dbsLinkedData As Database
-
Dim rstQAssignedHrsSum As dao.Recordset
-
Dim rstTblAssignHrs As dao.Recordset
-
Dim strSeekProjID As String
-
Dim strSeekSessionID As String
-
Dim nullvalue As Variant
-
Dim rstExpr1 As String
-
Dim SumOfHrs As Integer
-
Dim HrsStore As Integer
-
Dim HrsTotal As Integer
-
Dim rstProjID As Integer
-
Dim rstSessTypeID As Integer
-
Dim rstCompletedHrs As Variant
-
Dim varbookmark As Variant
-
Dim TableAssignhrs As Integer
-
Dim SessTypeStore As Integer
-
-
-
-
'sets quer recordset and the the table where the data is going to be written
-
-
Set dbsCurrent = CurrentDb
-
Set dbsLinkedData = DBEngine.OpenDatabase("C:\Database\ClientBooking\ExampleAccess2000")
-
Set rstTblAssignHrs = _
-
dbsLinkedData.OpenRecordset("T_AssignHours", dbOpenTable)
-
Set rstQAssignedHrsSum = _
-
dbsCurrent.OpenRecordset("Q_SFormTotalHrs1", dbOpenDynaset)
-
-
-
strSeekProjID = Forms![F_ClientDetails]![SF_Session].Form![ProjID]
-
strSeekSessionID = Forms![F_ClientDetails]![SF_Session].Form![SessTypeID]
-
-
With rstQAssignedHrsSum
-
-
Do
-
' loops round and totals up hours ready to be written to table
-
Do Until rstQAssignedHrsSum.EOF
-
-
-
rstExpr1 = rstQAssignedHrsSum!expr1
-
HrsStore = HrsStore + rstExpr1
-
-
.MoveNext
-
HrsTotal = HrsTotal + HrsStore
-
HrsStore = 0
-
-
Loop
-
-
Loop Until rstQAssignedHrsSum.EOF
-
-
.Close
-
-
End With
-
-
'loops table until record is found and writes data to field
-
With rstTblAssignHrs
-
-
Do
-
-
Do Until rstTblAssignHrs.EOF
-
-
-
rstProjID = rstTblAssignHrs!projectID
-
rstSessTypeID = rstTblAssignHrs!SessTypeID
-
-
-
If rstProjID = strSeekProjID And rstSessTypeID = strSeekSessionID Then
-
-
rstTblAssignHrs.Edit
-
-
-
rstTblAssignHrs!completedHrs = HrsTotal
-
rstTblAssignHrs.Update
-
-
End If
-
-
.MoveNext
-
-
Loop
-
-
Loop Until rstTblAssignHrs.EOF
-
-
.Close
-
-
End With
-
'Exit_Command16_Click:
-
-
Exit Function
-
'Err_Command16_Click:
-
-
' MsgBox Err.Description
-
' Resume Exit_Command16_Click
-
Exit Function
-
End Function
-
4 1692
the recordset below totals the number of hours worked on a session type 1
and then writes that value to a table.
Is there a paticular reason that you need to write this data to a table? You would be much better off using a query to calculate the totals as you require them. That way each time the query is run you would have a freshly updated set of totals.
NeoPa 32,568
Recognized Expert Moderator MVP
This seems a very straightforward problem (not sure why such complex explanation).
This illustrates the very common problem you get when you fail to use the database as a database and try to make it into a transaction processing system.
This issue is often referred to as Normalisation. Check out Normalisation and Table structures for a fuller explanation.
NeoPa 32,568
Recognized Expert Moderator MVP
By the way, it's possible to use Access as a transaction processing system. It's actually quite flexible that way, but as it's an RDBMS, and it gives you all that goes with that, you'd need a fairly good reason to want to go what is essentially the more difficult route.
Hi Neopa and DonRayner
I have found a solution
Thanks for your help
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: dixie |
last post by:
I have a form full of subforms which bring summary information onto the form
from about 12 different tables. I am trying to get all of that summary
information (mainly numbers) into 1 large table that represents the final
results for the year. The table into which I wish to save it has 10
records, the past 10 years results. The problem is that I select the
calendar year from an unbound combo box and it runs a filter that restricts
the...
|
by: CFW |
last post by:
I thought this was going to be easy but I'm missing something . . . I
need to open an ADODB recordset using the recordset source for a list
box on my for. When my form opens, the list box ADODB recordset is
established and set during On Open. Next I want to populate a
recordset from that list box so I can filter it on a single field
using the value of a combo box for the filter string. I have a second
combo box that i woul like to use...
|
by: CSDunn |
last post by:
Hello,
In Access ADP's that connect to SQL Server databases, any time I have
a situation where I have a combo box in a main form that looks up a
record in a subform, the subform record source has to be based on
either a View or a Table. I can almost always use a View, and it helps
to do this since I can have better control over the size of the
RecordSet of the subform.
There are times when the use of a Stored Procedure would give me...
|
by: airman_30 |
last post by:
i am opening a recordset in my VB code and populating a combo box with
the data from one of the fields in my recordset. I want to set it up so
that, when a user selects one of the values from the combo box, the
text boxes on the form will be populated with the associated data. This
is driving me insane! I've researched almost all day on this, and can't
seem to find an answer. Any help would would be HUGELY appreciated as
this is part of a...
|
by: Laphan |
last post by:
Hi All
I know you will probably say that I should use MS SQL Server DBs with ASP,
but my MySQL and ASP combo works and is affordable for me and up until now
didn't give me any grief until recently.
In essence, the following MySQL query commands cause my ASP to generate a
Type Mismatch error when I try to response.write the result of the query
fields:
| |
by: technocraze |
last post by:
Hi guys,
I have encountered this error when updating the values to the MS Acess table.
Error : Update on linked table failed. ODBC sql server error Timeout expired. MS Acess is my front end and sql server is my backend server.
This error occured whenever i step through and when it reaches rs.update it jux hangs down there and thereafter it shwn the aforementioned error. I am using the RecordSet properties to add the values. Can I use...
|
by: Kev |
last post by:
Hello,
I have an Access 2003 database running on an XP network.
I have a datasheet subform containing a 28 day roster - shift1 to
shift28.
Each record has 1 RosterEmpID, 1 EmployeeNumber, 28 shift fields, and
1 shiftTotal field and 1 HoursTotal field.
Datasheet may look like:
|
by: Tom Clavel |
last post by:
Scratching my head.
I am using the filter property on a combo box .AfterUpdate event to
get to a single client record. This is causing a some strange
behavior: As I enter a subform, I get a no current record error. This
is strange to me because: I can see the record contents displayed on
the form, and debug.printing them gets me the values. Only the
form.recordset is giving me this error. form.recordset .bof and .eof
are false. ;...
|
by: omar.norton |
last post by:
I am trying to create a from with a series of combo boxes that each
query a different field (called Specific01, Specific02 etc., except
the first field which is called Condition). Each combo box has a SQL
statement in it's rowsource so it will only display distinct records
in it's field where all the previous fields match the choices chosen
in previous combo boxes, so eventually your choices will be narrowed
down until you come up with a...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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: 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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |