How to select top 10 in Access query?

select top 10 Name, Price from MyTable order by Price desc Updated: @Fionnuala pointed out that: “Access SQL selects matches, so it will select all items with the same highest prices, even if this includes more than 10 records. The work-around is to order by price and a unique field (column).” So, if you have … Read more

insert query with sequential primary key

Here are some notes that may help you towards your goal, however life would be a lot easier and a lot safer with autonumbers. This is VBA as you mention MS Access. Function NextTranNumber(ByRef FirstTran As Long, _ ByRef LastTran As Long, Optional BlockSize = 1) Dim cn As New ADODB.Connection Dim rs As New … Read more

Access 2007 – Left Join to a query returns #Error instead of Null

While the query should return Null based on the join type, as Allen Browne states in his article, Bug: Outer join expressions retrieved wrongly, “Instead, it behaves as if [the JET query optimizer] is evaluating the expression after it has returned the results from the lower-level query.” Consequently, you must select the calculated field using … Read more

MS Access LIMIT X, Y

While the Access/JET TOP keyword does not directly provide an OFFSET capability, we can use a clever combination of TOP, a subquery, and a “derived table” to obtain the same result. Here is an example for getting the 10 rows starting from offset 20 in a Person table in ORDER BY Name and Id… SELECT … Read more

Pivot Query in MS Access

Consider: TRANSFORM First(Data.Cat) AS FirstOfCat SELECT Data.ID, Data.Name FROM Data GROUP BY Data.ID, Data.Name PIVOT “Cat” & DCount(“*”,”Data”,”ID=” & [ID] & ” AND Cat<‘” & [Cat] & “‘”)+1; Or if there is a unique record identifier field – autonumber should serve: TRANSFORM First(Data.Cat) AS FirstOfCat SELECT Data.ID, Data.Name FROM Data GROUP BY Data.ID, Data.Name PIVOT … Read more

Equivalent cURL in VBA?

Solved it now guys, works well. For other peoples convenience. TargetURL = “https://www.mysite.co.uk/app/api/v1/test” Set HTTPReq = CreateObject(“WinHttp.WinHttpRequest.5.1”) HTTPReq.Option(4) = 13056 ‘ HTTPReq.Open “PUT”, TargetURL, False HTTPReq.SetCredentials “user”, “password”, 0 HTTPReq.setRequestHeader “Content-Type”, “application/x-www-form-urlencoded” HTTPReq.send (“test[status]=” & Forms!curl!Text0.Value & “&test2[status]=” & Text2.Value) MsgBox (HTTPReq.responseText)

tech