473,659 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

recordset and combo box issues

121 New Member
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

Expand|Select|Wrap|Line Numbers
  1. 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
  2. FROM T_ActiveSession
  3. 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
  4. HAVING (((T_ActiveSession.ProjID)=SubFormFieldValue("F_ClientDetails","SF_Session","ProjID")) AND ((T_ActiveSession.SessTypeID)=SubFormFieldValue("F_ClientDetails","SF_Session","sesstypeid")))
  5. ORDER BY T_ActiveSession.SessTypeID;
  6.  
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim dbsCurrent As Database
  3.     Dim dbsLinkedData As Database
  4.     Dim rstQAssignedHrsSum As dao.Recordset
  5.     Dim rstTblAssignHrs As dao.Recordset
  6.     Dim strSeekProjID As String
  7.     Dim strSeekSessionID As String
  8.     Dim nullvalue As Variant
  9.     Dim rstExpr1 As String
  10.     Dim SumOfHrs As Integer
  11.     Dim HrsStore As Integer
  12.     Dim HrsTotal As Integer
  13.     Dim rstProjID As Integer
  14.     Dim rstSessTypeID As Integer
  15.     Dim rstCompletedHrs As Variant
  16.     Dim varbookmark As Variant
  17.     Dim TableAssignhrs As Integer
  18.     Dim SessTypeStore As Integer
  19.  
  20.  
  21.  
  22.   'sets quer recordset and the the table where the data is going to be written
  23.  
  24.     Set dbsCurrent = CurrentDb
  25.     Set dbsLinkedData = DBEngine.OpenDatabase("C:\Database\ClientBooking\ExampleAccess2000")
  26.     Set rstTblAssignHrs = _
  27.         dbsLinkedData.OpenRecordset("T_AssignHours", dbOpenTable)
  28.     Set rstQAssignedHrsSum = _
  29.       dbsCurrent.OpenRecordset("Q_SFormTotalHrs1", dbOpenDynaset)
  30.  
  31.  
  32.     strSeekProjID = Forms![F_ClientDetails]![SF_Session].Form![ProjID]
  33.     strSeekSessionID = Forms![F_ClientDetails]![SF_Session].Form![SessTypeID]
  34.  
  35. With rstQAssignedHrsSum
  36.  
  37. Do
  38. ' loops round and totals up hours ready to be written to table
  39. Do Until rstQAssignedHrsSum.EOF
  40.  
  41.  
  42.         rstExpr1 = rstQAssignedHrsSum!expr1
  43.         HrsStore = HrsStore + rstExpr1
  44.  
  45.         .MoveNext
  46.         HrsTotal = HrsTotal + HrsStore
  47.         HrsStore = 0
  48.  
  49. Loop
  50.  
  51. Loop Until rstQAssignedHrsSum.EOF
  52.  
  53.         .Close
  54.  
  55. End With
  56.  
  57. 'loops table until record is found and writes data to field
  58. With rstTblAssignHrs
  59.  
  60.     Do
  61.  
  62.     Do Until rstTblAssignHrs.EOF
  63.  
  64.  
  65.         rstProjID = rstTblAssignHrs!projectID
  66.         rstSessTypeID = rstTblAssignHrs!SessTypeID
  67.  
  68.  
  69.      If rstProjID = strSeekProjID And rstSessTypeID = strSeekSessionID Then
  70.  
  71.         rstTblAssignHrs.Edit
  72.  
  73.  
  74.         rstTblAssignHrs!completedHrs = HrsTotal
  75.         rstTblAssignHrs.Update
  76.  
  77.         End If
  78.  
  79.         .MoveNext
  80.  
  81.     Loop
  82.  
  83. Loop Until rstTblAssignHrs.EOF
  84.  
  85.         .Close
  86.  
  87.     End With
  88. 'Exit_Command16_Click:
  89.  
  90.  Exit Function
  91. 'Err_Command16_Click:
  92.  
  93.   '  MsgBox Err.Description
  94.   '  Resume Exit_Command16_Click
  95. Exit Function
  96. End Function
  97.  
Jan 23 '09 #1
4 1692
DonRayner
489 Recognized Expert Contributor
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.
Jan 23 '09 #2
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.
Jan 25 '09 #3
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.
Jan 25 '09 #4
phill86
121 New Member
Hi Neopa and DonRayner

I have found a solution

Thanks for your help
Jan 29 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3879
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...
0
2649
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...
0
2349
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...
2
1424
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...
2
4398
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:
2
4802
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...
4
2791
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:
2
10451
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. ;...
1
1901
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...
0
8330
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,...
0
8850
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, 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...
0
8746
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 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...
1
8523
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,...
0
7355
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, 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...
1
6178
isladogs
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...
0
4175
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...
1
2749
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
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.