ms-access-2007

Transpose a table using query in Access

醉酒当歌 提交于 2019-12-18 07:31:51
问题 I have the table1, i want to transpose it as shown in table1_1, can anyone tell me the query/function that can be used to do this table 1 FileName ObjectName Column1 Column2 Column3 Column4 Column5 F1 Line1 A B C D E F1 Line2 F G H I J F1 Line3 K L M N O table1_1 FileName ObjectName Column Data F1 Line1 Column1 A F1 Line1 Column2 B F1 Line1 Column3 C F1 Line1 Column4 D F1 Line1 Column5 E F1 Line2 Column1 F F1 Line2 Column2 G F1 Line2 Column3 H F1 Line2 Column4 I F1 Line2 Column5 J F1 Line3

“Save as…” dialog box in MSAccess vba: how?

*爱你&永不变心* 提交于 2019-12-18 07:25:10
问题 In MSAccess I've a mask with a button. When the user clicks on the button, the data in a table are exported on a .txt file: Private Sub Command_Click() Dim Rst As DAO.Recordset Dim AField As DAO.Field Dim TempStr As String Dim FileNumber FileNumber = FreeFile Open "c:\table.txt" For Output As #FileNumber Set Rst = CurrentDb.OpenRecordset("Tabella1", dbOpenForwardOnly) Do While Not Rst.EOF For Each AField In Rst.Fields If (AField.Name <> "ID") Then TempStr = TempStr & AField.value & " " End If

“Save as…” dialog box in MSAccess vba: how?

余生颓废 提交于 2019-12-18 07:25:09
问题 In MSAccess I've a mask with a button. When the user clicks on the button, the data in a table are exported on a .txt file: Private Sub Command_Click() Dim Rst As DAO.Recordset Dim AField As DAO.Field Dim TempStr As String Dim FileNumber FileNumber = FreeFile Open "c:\table.txt" For Output As #FileNumber Set Rst = CurrentDb.OpenRecordset("Tabella1", dbOpenForwardOnly) Do While Not Rst.EOF For Each AField In Rst.Fields If (AField.Name <> "ID") Then TempStr = TempStr & AField.value & " " End If

Update MSAccess table from another Access table using SQL

一个人想着一个人 提交于 2019-12-17 20:27:41
问题 I am trying to update table Original with the values in Final. I'm a newb to SQL, but I have been at this for two hours trying to change various samples to fit my needs. I am using Access 2007. UPDATE Original o SET o.[Assest Description] = ( SELECT f.[Assest Description] FROM Original o, Final f WHERE o.[Assest No] = f.[Assest No]) WHERE o.[Assest No] = Final.[Asset No] 回答1: I'm not sure your select statement returns only one row. If you want to perform an update on a table using a select

MS Access call SQL Server stored procedure

吃可爱长大的小学妹 提交于 2019-12-17 18:52:46
问题 I have an MS Access application that contains all tables linked to SQL Server, so in MS Access VBA code or query I work with those tables very simple, I access them via name, like [Customers] . Also I have a stored procedure in SQL Server called sp_CopyData which I need to call from my VBA code. How can I do that without creating new connection to SQL Server (I already have it somewhere!? because I have access to tables)? Or it's impossible? Appreciate any help. Thanks! 回答1: The right answer

How to execute query saved in MS Access using pyodbc

霸气de小男生 提交于 2019-12-17 16:53:40
问题 There are a lot of tips online on how to use pyodbc to run a query in MS Access 2007, but all those queries are coded in the Python script itself. I would like to use pyodbc to call the queries already saved in MS Access. How can I do that? 回答1: If the saved query in Access is a simple SELECT query with no parameters then the Access ODBC driver exposes it as a View so all you need to do is use the query name just like it was a table: import pyodbc connStr = ( r"Driver={Microsoft Access Driver

Concatenate fields from one column in one table into a single, comma delimited value in another table

跟風遠走 提交于 2019-12-17 14:21:14
问题 Any help that can be provided to a Access and VB noob would be greatly appreciated. What I'm trying to do is concatenate the values from one table and insert it as a comma delimited value into a field in another table. I'm trying to take all the server names that are say Linux boxes and concatenate them into a different field. Table A looks like this Machine Name | Zone | Operating System ---------------------------------------- Server01 Zone A Linux Server02 Zone B Linux Server03 Zone A

How to show row number in Access query like ROW_NUMBER in SQL

对着背影说爱祢 提交于 2019-12-17 07:39:38
问题 I have a table in Microsoft Access, and I want to show row number in a column using a select query in Access just like using ROW_NUMBER() function in SQL Server. In SQL Server, I can using this query: SELECT ROW_NUMBER() OVER (ORDER BY tblUser.UserID) AS NoRow, * FROM tblUser I use same query in access, but I get error. Can you help me? 回答1: You can try this query: Select A.*, (select count(*) from Table1 where A.ID>=ID) as RowNo from Table1 as A order by A.ID 回答2: One way to do this with MS

Combine rows / concatenate rows

倖福魔咒の 提交于 2019-12-16 20:04:21
问题 I'm looking for an Access 2007 equivalent to SQL Server's COALESCE function. In SQL Server you could do something like: Person John Steve Richard SQL DECLARE @PersonList nvarchar(1024) SELECT @PersonList = COALESCE(@PersonList + ',','') + Person FROM PersonTable PRINT @PersonList Which produces: John, Steve, Richard I want to do the same but in Access 2007. Does anyone know how to combine rows like this in Access 2007? 回答1: Here is a sample User Defined Function (UDF) and possible usage.

Crosstab query with selected range of copyright year as column heading

蓝咒 提交于 2019-12-14 04:22:36
问题 This is another question that is related to my previous post at my post here but with different problem. In my previous post, I ask on how I can create a crosstab query that will output a column based on 4 year range of copyright year. The answer was very good but now I am facing another challenge. To be clear here's the data on the table: ID CallNo CopyrightYear 1 AH 2000 2 AB 2000 3 BC 2001 4 AH 2000 5 ZA 2005 6 BC 2001 7 AP 2003 10 ZA 2006 11 DA 2009 12 DA 2010 13 RA 1999 14 WE 1997 15 HK