Getting total in one line of the query

silentwolf

Active member
Local time
Today, 00:39
Joined
Jun 12, 2009
Messages
591
Hi guys,

I am starting a new threat but it does relate to my previous question on following threat


Not sure if that is how I suppose to refer to the other threat hope I did that right?

However I got tblAppartment, tblAppRoom and tblRoom

Shown in the below pic.

I like to create a Query that allows me get totalLivingSpace of that Appartment and the TotalSize of the Appartment like Shown in the picture I got from the Form.

The reason is to use those sqm in a Word Document as bookmarks.

For example in the Word Document.

Appartment XYZ has LivingRoom, Bedroom, Kitchen, Toilet, Bath, Balkony, ParkingArea, of total Living Space of 70 sqm and a Total Area of 75 sqm as an Balkony is not part of LivingSpace.

TheDBGuy has providet a SimpleCSV Function where I can get the Rooms of the appartment in one Field. Great function by the way ;)
so how can I ajust it so I can get the total Sizes also into the query.

So I can have one Query providing me with AppartmentName or Address, all the rooms for that appartment, and livingRoomSizeTotal and TotalAppartmentSize which I can then use to fill bookmarks to my document,

Many thanks for your help.

oh here is the Code from TheDBGuy

Code:
Public Function SimpleCSV(strSQL As String, _
            Optional strDelim As String = ",") As String
'Returns a comma delimited string of all the records in the SELECT SQL statement
'Source: http://www.accessmvp.com/thedbguy
'v1.0 - 8/20/2013

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strCSV As String

Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)

'Concatenate the first (and should be the only one) field from the SQL statement
With rs
    Do While Not .EOF
        strCSV = strCSV & strDelim & .Fields(0)
        .MoveNext
    Loop
    .Close
End With

'Remove the leading delimiter and return the result
SimpleCSV = Mid$(strCSV, Len(strDelim) + 1)

Set rs = Nothing
Set db = Nothing

End Function

Many thanks for your help

Albert
 

Attachments

  • AppartmentRooms.JPG
    AppartmentRooms.JPG
    19.7 KB · Views: 12
  • AppartmentRooms_N.JPG
    AppartmentRooms_N.JPG
    23.4 KB · Views: 9
  • AppartmentRoomsSizes.JPG
    AppartmentRoomsSizes.JPG
    39.4 KB · Views: 11
You could write another function to do that, but it would simply modify this. I will take a look at it.
Not sure if that is how I suppose to refer to the other threat hope I did that right?
Perfect. Have to go back and look at that one.
 
Hi MajP,

thanks alot for taking a look at it!

Cheers!
 
I am going to assume that in your table tblAppRooms RaumGrosse (RoomSize) field or something like that?
 
Yes sorry that is right mixed it with german oops

I guess that was still the old version now as shown below in the pic are to updated fields it is now calles AppRoomSize just for your info
 
Yes sorry that is right mixed it with german oops
I mean you now have some fields in that Table called tblAppRooms.
I would also think in that table you have a field called LivingSpace (yes no) so you can calculate living space vs total space.
 
In my database is now as the pic providet in this threat.


tblAppRoom
AppRoomID
AppID
RoomID
AppRoomSize
IsLivingSpace ....YesNo
Unit

I guess in the old threat there where still old namings
 
See qryApartment Summary. The space should be done with simple aggregate queries and not a function
P8.PNG
 

Attachments

I forgot to get the count of livable rooms but look at the query for livable space and see if you can figure it out. Just add a count of rooms.
 
Oh ok, I will let you know how I did manage :)

Cheers just got it working with my new Version fantastic work MajP!!

Many thanks
 
I use this website all the time because it is very clear and basic. You can go through it and see the things you can do in sql.
 

Users who are viewing this thread

Back
Top Bottom