ms-access

Unpivot in Access SQL

假装没事ソ 提交于 2019-12-31 07:38:10
问题 Hi guys I'm trying to use unpivot in SQL on MS Access and I found the following code online: SELECT CustomerID, Phone FROM ( SELECT CustomerID, Phone1, Phone2, Phone3 FROM dbo.CustomerPhones ) AS cp UNPIVOT ( Phone FOR Phones IN (Phone1, Phone2, Phone3) ) AS up; from this webpage: https://www.mssqltips.com/sqlservertip/3000/use-sql-servers-unpivot-operator-to-help-normalize-output/ However when I tried the exact same code on Access, it keeps saying the FROM clause has an error. I wonder if

Displaying selected values only in VB6

左心房为你撑大大i 提交于 2019-12-31 07:31:27
问题 I am trying to display students in a datagrid that have "yes" as active. If the student has "no" as active, the form has to hide it and only show the students with "yes". The problem that I am recieving now is Syntax error in FROM clause. code: Private Sub Form_Load() Dim sql As String connSearch.Open connstr Adodc1.ConnectionString = conn.connstr sql = "select * from Table1 where Active <>" & "'No'" Adodc1.RecordSource = sql Set StudentTable.DataSource = Adodc1 Adodc1.Refresh Adodc1.Visible

Displaying selected values only in VB6

馋奶兔 提交于 2019-12-31 07:31:19
问题 I am trying to display students in a datagrid that have "yes" as active. If the student has "no" as active, the form has to hide it and only show the students with "yes". The problem that I am recieving now is Syntax error in FROM clause. code: Private Sub Form_Load() Dim sql As String connSearch.Open connstr Adodc1.ConnectionString = conn.connstr sql = "select * from Table1 where Active <>" & "'No'" Adodc1.RecordSource = sql Set StudentTable.DataSource = Adodc1 Adodc1.Refresh Adodc1.Visible

Return all nodes in many-to-many hierarchal tree

扶醉桌前 提交于 2019-12-31 07:25:09
问题 Similar to this question: How do I query for all the nodes between two nodes in a tree? But I do not have a closure (flattened) table, a child can have many parents, and ID traversal is not necessarily in order. There is no limit to the nesting depth. Assume a circular reference is impossible... I would like to return all rows required to traverse the hierarchy. Assume the following table: ParentID ID RowNumber(Reference) 1 2 1 2 4 2 4 3 3 3 5 4 1 6 5 6 7 6 2 8 7 3 9 8 1 8 9 6 8 10 Given 1

SQL Update Statement

天涯浪子 提交于 2019-12-31 06:54:39
问题 I have 2 tables, Products and ShoppingCart and I would like to update and decrease the product's 'Quantity' of the Products table based on the Product name and Quantity specified in the ShoppingCart. How can i do this? Table: Products Fields: ProductName, ProductQty Table: Shopping Cart Fields: ProductName, ProductQty Access DB 回答1: You should have a product id. However: UPDATE Products p INNER JOIN [Shopping Cart] s ON p.[Product Name] = s.[Product Name] SET p.ProductQty = p.ProductQty - s

What is the difference between using currentproject.connection vs connection strings for ADO object?

别说谁变了你拦得住时间么 提交于 2019-12-31 06:22:03
问题 We can set up the connection string for ADO connection using either currentproject.connection or using a DSN ( DSN=MyDSN;UID=MyID;PWD=MyPwd ) or DSN-Less connection string( DRIVER=\{SQL Server\};SERVER= MyServer;DATABASE=pubs; UID=MyID;PWD=MyPwd) My question is specifically in the case of linked tables connected to SQL Server. I have a DSN-less linked tables connected to SQL Server backend. I used this code provided by microsoft to create the DSN-less connection. If I do debug.print

What is the difference between using currentproject.connection vs connection strings for ADO object?

≯℡__Kan透↙ 提交于 2019-12-31 06:21:06
问题 We can set up the connection string for ADO connection using either currentproject.connection or using a DSN ( DSN=MyDSN;UID=MyID;PWD=MyPwd ) or DSN-Less connection string( DRIVER=\{SQL Server\};SERVER= MyServer;DATABASE=pubs; UID=MyID;PWD=MyPwd) My question is specifically in the case of linked tables connected to SQL Server. I have a DSN-less linked tables connected to SQL Server backend. I used this code provided by microsoft to create the DSN-less connection. If I do debug.print

MSAccess using a wildcard in the REPLACE function

主宰稳场 提交于 2019-12-31 05:42:29
问题 I'm trying to do something simple and I don't understand why it's not working. I'm really new to MS Access VBA. I have a string in a textbox : \\p9990cdc\C$\Temp I want to turn it into : C:\Temp I'm trying : strSelectedFile = Replace(strSelectedFile, "\\*\C$", "C:") and it's not working. Not sure why RegEx doesn't work either : strSelectedFile = Replace(strSelectedFile, "\\[\w]\C$", "C:") Everything is set properly so the problem lies exactly in that replace code, because if I try for example

Joining Two Tables with Different Data types MS ACCESS - 'type mismatch in expression' error

人走茶凉 提交于 2019-12-31 05:34:07
问题 I'm trying to run a query on access using two live CSVs which has a common field with different data types(numbers and short text). I've discovered that you can join different data types using 'CStr'. I've added the 'CStr' to my code on the sql view. Please find the see the code below. This gives me the output i want on access and i can now see the output when i click on 'datasheet view'. However, when i try to export the data (i'm actually trying create a export specification so that i can

Combine 2 queries with sum involved

浪子不回头ぞ 提交于 2019-12-31 05:26:09
问题 I have 2 similar queries that both look like this with only the table being switched from Treatment to Patient in the second query: SELECT Treatment.Phys_ID AS Phys_ID, Physician.FName, Physician.LName, Sum(Treatment.Charge) AS TotCharge FROM Physician INNER JOIN Treatment ON Physician.Phys_ID = Treatment.Phys_ID GROUP BY Treatment.Phys_ID, Physician.FName, Physician.LName; The output of both is: Phys_ID___FName___LName____TotCharge When combined, I need to add the 2 queries' columns of