access-vba

DMedian in access 2013, no values returned

半世苍凉 提交于 2020-01-11 12:45:07
问题 I have the following query in MS Access 2013 than does not return a Median value. The field IU is always NULL (blank) or 1. Column GM is a number formatted 0.0000 between -5 and 5 with NULL values in it occasionally. SELECT IU, DMedian("GM","tblFirst250","IU=1") AS MedianByIU FROM tblFirst250 WHERE IU = 1 GROUP BY IU; However, while attempting to debug this, when I use DAvg instead of DMedian I get an Average value. I got DMedian (because I understood that Access 2013 didn't have it) from:

access-SQL pass-through query (creating SP) error

谁说胖子不能爱 提交于 2020-01-11 10:18:14
问题 I am trying to create a stored procedure using pass-through query in SQL Server 2012, using MS Access 2010. IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = N'SCHtest') EXECUTE sp_executesql N'create schema SCHtest' GO CREATE PROCEDURE [SCHtest].[SQLLrtest_2] AS BEGIN INSERT INTO [dbo].[UploadTest] (.....) In Access I get this error: Run time error '3146': [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax nera 'GO'. (#102) [Microsoft][ODBC SQL Server Driver][SQL Server]

Accessing Field2 in Access 2007

浪子不回头ぞ 提交于 2020-01-11 07:39:08
问题 I'm trying to write a simple little routine to email an attachment stored in an Access 2007 database. For some reason I cannot get the simplest part of it to work. I get an error saying "User-defined type not defined" on the following line: Dim attachmentField As DAO.Field2 Now up to this point I haven't accessed any DAO objects yet, but my assumption was that I only needed to add the relevant reference. Thing is, I seem to have a misconception about what that reference is. I have tried

“The data has been changed” error when stepping from main form into sub form

为君一笑 提交于 2020-01-11 04:54:10
问题 I'm migrating an Access database to SQL Server using the SQL Server Migration Assistant (SSMA). The Access application will continue to be used but with linked tables instead of local ones. I've run into a problem during the post-migration testing with a form that contains several sub forms. Testing steps: 1) Edit a field in the main form; 2) Shift focus to a field in the sub form; 3) Attempt to edit the field in the sub form. Result: An error message pops up: "The data has been changed.

Insert INTO NOT EXISTS SQL access

眉间皱痕 提交于 2020-01-10 05:41:10
问题 I am trying to insert records from another table into a table in Access using sql. I have pasted the statement below. I want to insert the records that exist in ImportMetricsIDs01262015 but not in ShouldImportMetricsIDs. It runs perfectly without any errors but it won't insert anything even when I physically add a new record. INSERT INTO ShouldImportMetricsIDsTable ( [Formulary ID], [Market Segment] ) SELECT ImportMetricsIDs01262015.[Formulary ID], ImportMetricsIDs01262015.[Market Segment]

SQL / VBScript / Intelligent Algorithm to find sum combinations quickly

徘徊边缘 提交于 2020-01-07 08:27:26
问题 Am trying to list out all the possible sequential (continuous and forward direction only) sum combinations , within the same subject. Listing out the row_id and the number of rows involved in the sum. Sample : Input (Source Table :) DLID Subject Total 1 Science 70 2 Science 70 3 Science 70 4 Science 70 5 Maths 80 6 Maths 80 7 English 90 8 English 90 9 English 90 10 Science 75 Expected Result : ID Number of Rows Subject Total 1 1 Science 70 2 1 Science 70 3 1 Science 70 4 1 Science 70 5 1

Close specific Excel file opened by user from Access-VBA

痴心易碎 提交于 2020-01-07 04:01:12
问题 I see version of how to do this with Dim ran as Excel.Applcation but the version of Access I am using doesn't have Excel.Application as an option. I have written the following code that runs, but does not close the file Dim Path1 as String Dim objXL As Object Dim xlWB As Object Path1 = "C:/....." Set objXL = CreateObject("Excel.Application") Set xlWB = objXL.Workbooks.Open(Path1) xlWB.Close False Set xlWB = Nothing objXL.Quit Set objXL = Nothing 回答1: You can use the following code to close

Automatically generate numbers

China☆狼群 提交于 2020-01-07 03:57:21
问题 I am in need of a tracking number that automatically generates. I added this in the 'Before Insert' action (see below), but I am having a problem after the number 9. Me![Tracking#] = Nz(DMax("[Tracking#]", "[TblTrackingNum]"), 0) + 0.01 My tracking number always starts of with 89669. This code works until it reaches the number ten. The tracking number should do this: 89669.1... 89669.2... 89669.3... 89669.4... 89669.5..... But after 9 it changes the number to 89670. I need it to say 89669.10.

Make Fileds compulsory if a particular filed is filled in Access Form

巧了我就是萌 提交于 2020-01-07 03:24:14
问题 I have a form in access, where I want to make 3 fields ( FYear , cboPeriodicity , cboPeriod ) compulsory if another field cboCompliance is filled in by user. I have tried the below code, where I am canceling save, if any of these fields are Empty. And also giving error message through msgBox Private Sub Form_BeforeUpdate(Cancel As Integer) On Error GoTo Form_BeforeUpdate_Err 'Audit Data Values Set Me.LastModifiedBy.Value = [TempVars]![currentUserID] Me.LastModifiedTime.Value = Now() 'If

Copying Text using ClipBoard_SetData() doesn't work

随声附和 提交于 2020-01-07 02:24:09
问题 I'm calling a function to copy text to the Windows clipboard using the API function from http://support.microsoft.com/kb/210216 using Access 2003 on Windows XP. The function does clear the Clipboard, but it silently fails on the actual assignment to the clipboard. Stepping through the code and querying for errors in the immediate window yields nothing. I copied and pasted the MS function exactly as shown on their webpage. 回答1: I use this function, which does almost exactly the same thing. It