From: Parag on 31 Mar 2010 17:01 I have a bunch of columns e.g. Day1-A, Day1-B,... Day2-A, Day2-B, etc. and want to write a query to for example, return all Day2 columns only. How do I do this please?
From: Salad on 31 Mar 2010 17:50 Parag wrote: > I have a bunch of columns e.g. Day1-A, Day1-B,... Day2-A, Day2-B, etc. > and want to write a query to for example, return all Day2 columns > only. > > How do I do this please? I created a table called Table1 with 4 fields; ID, First, Last, Addr. I then ran this code and it displayed ID1, FirstName, LastName, Address. Sub QueryHeads() Dim strQuery As String Dim rst As Recordset Dim fld As Field Dim intFor As Integer strQuery = "Select ID As ID1, First As FirstName," & _ "Last As LastName, Addr As Address From Table1" Set rst = CurrentDb.OpenRecordset(strQuery, dbOpenSnapshot) For intFor = 0 To rst.Fields.Count - 1 Debug.Print rst(intFor).Name & " " Next rst.Close Set rst = Nothing End Sub That might not be what you want. Check out this link http://bytes.com/topic/access/answers/870485-update-tables-caption And this as well http://www.fmsinc.com/tpapers/access/Reports/monthly/index.html
From: Rich P on 31 Mar 2010 17:55 The easiest way to query your columns is to design your table according to the Relational model. This model is the RDBMS standard and states that detail data consisting of the same data type - should be contained in the same column. This means that if the data in your column Day1-A and Day1-B, ... are of the same type (like all numbers or all text) you should contain the data in each of your columns in one column - call it Days. Lets say your data is all numeric, then you would add another column that would specify which days belong to A, B, C, ... DayLetter Days A 1 A 2 A 3 ... B 1 B 2 B 3 ... C 1 C 2 ... Now you can write a query like this: Select Days from tbl1 Where DayLetter = 'B'. This is the relational model. Rich *** Sent via Developersdex http://www.developersdex.com ***
|
Pages: 1 Prev: My database window objects became hyperlinks Next: 2007 extremely slow |