vba

Run-time error '3065' Cannot execute a select query

空扰寡人 提交于 2021-02-19 04:17:54
问题 I have written lots of the queries but I'm struggling with this one. I get the run-time error 3065 when I run the following sql. Dim db As DAO.Database Dim sqlstring As String Set db = DBEngine(0).Databases(0) sqlstring = "SELECT ebk.hr_leav_amnt AS hr_clia_hour, ebk.hr_leav_type, ebk.hr_leav_code, ebk.hr_empl_code, ebk.hr_loadg_amt AS hr_loadg_amt, 'Leave Pay' AS hr_provision, mst.hr_paym_code, mst.hr_base_hour, '' AS hr_splt_accr, mst.hr_leav_abbr, ype.hr_norm_pcnt, ype.hr_allw_amnt"

Run-time error '3065' Cannot execute a select query

心不动则不痛 提交于 2021-02-19 04:17:13
问题 I have written lots of the queries but I'm struggling with this one. I get the run-time error 3065 when I run the following sql. Dim db As DAO.Database Dim sqlstring As String Set db = DBEngine(0).Databases(0) sqlstring = "SELECT ebk.hr_leav_amnt AS hr_clia_hour, ebk.hr_leav_type, ebk.hr_leav_code, ebk.hr_empl_code, ebk.hr_loadg_amt AS hr_loadg_amt, 'Leave Pay' AS hr_provision, mst.hr_paym_code, mst.hr_base_hour, '' AS hr_splt_accr, mst.hr_leav_abbr, ype.hr_norm_pcnt, ype.hr_allw_amnt"

How to create and set a ActiveX Control CommandButton as a variable Excel VBA

£可爱£侵袭症+ 提交于 2021-02-19 03:11:57
问题 I am trying to Create a New ActiveX Control CommandButton with Excel VBA. I have a loop VBA which has worked in the past, theFile1.1.xlsm has the master list of the workbooks. I need to add a CommandButton to ~3200 workbooks, so I will be using the Do-Loop macro. Here is the Loop code for reference. Sub Macro2() Application.ScreenUpdating = False Dim sFile As String Dim wb As Workbook Dim FileName1 As String Dim FileName2 As String Dim wksSource As Worksheet Const scWkbSourceName As String =

ADODB SQL Syntax - Access table Inner Join with Excel worksheet

匆匆过客 提交于 2021-02-19 02:36:09
问题 I have a project where users will need to fill out an Excel file and then export the data to an Access database. The data collected in the Excel file will need to be exported in 3 steps: (1) export data set 1 record, (2) query Access for the primary key (auto-number) of the newly imported record, (3) export data set 2 record, which includes the primary key populated as the foreign key. I am able to accomplish the first step by establishing and opening an ADODB connection. However, I am

Can I update an XML node value using a variable in VBA

核能气质少年 提交于 2021-02-19 02:00:08
问题 I am a complete newcomer to learning about XML but OK with VBA in Excel 2010. In Excel VBA I have created a simple CustomXMLPart with 5 nodes under a single root, akin to the example below: < <RefTest> <sRef1>SomeText</sRef1> 'text <sRef2>XYZ234</sRef2> 'text <sRef3>ABC123</sRef3> 'text <dRef4>25/02/1953</dRef4> 'date or text? <iRef5>0</iRef5> 'numeric or text? </RefTest> > This works OK and I can read the values back-in using VBA. My problem is that the node values (at the moment) are

When is it appropriate to explicitly use Err.Clear?

喜夏-厌秋 提交于 2021-02-18 22:12:07
问题 For example, the following function is used for checking whether a workbook is open: Function BookOpen(Bk As String) As Boolean Dim T As Excel.Workbook Err.Clear On Error Resume Next Set T = Application.Workbooks(Bk) BookOpen = Not T Is Nothing Err.Clear On Error GoTo 0 End Function Are these two Err.Clear statements necessary? 回答1: In this example Function BookOpen(Bk As String) As Boolean Dim T As Excel.Workbook Err.Clear On Error Resume Next Set T = Application.Workbooks(Bk) BookOpen = Not

When is it appropriate to explicitly use Err.Clear?

六月ゝ 毕业季﹏ 提交于 2021-02-18 22:10:14
问题 For example, the following function is used for checking whether a workbook is open: Function BookOpen(Bk As String) As Boolean Dim T As Excel.Workbook Err.Clear On Error Resume Next Set T = Application.Workbooks(Bk) BookOpen = Not T Is Nothing Err.Clear On Error GoTo 0 End Function Are these two Err.Clear statements necessary? 回答1: In this example Function BookOpen(Bk As String) As Boolean Dim T As Excel.Workbook Err.Clear On Error Resume Next Set T = Application.Workbooks(Bk) BookOpen = Not

MS Excel Vba Arabic unicode

北城余情 提交于 2021-02-18 19:42:38
问题 I have a text file and a macro enabled excel file. the excel file gets (using vba) the string (arabic text) from the text file per line then put it on the sheet1 cells. The problem is the string is not properly displayed. It is displayed in random Japanese characters. (My windows locale is Japan). Here is my code: Open FilePath For Inputs As #1 Do Until EOF(1) Line Input #1, textline ActiveWorkbook.sheets(1).Cell(1,1).Value = textline 'MsgBox(textline) Loop Close#1 Question: How can I get the

Array multiplication and matrix inversion with VBA

好久不见. 提交于 2021-02-18 19:35:24
问题 I am trying to do some calculations with arrays. e.g. I want to solve Ax=y , so I use the following code to do so, where A is a square matrix and y is a col. vector. In VBA, A is an array with two dimension and y is one with one dimension. However, this code does not work... x = WorksheetFunction.MMult(WorksheetFunction.MInverse(A), y) Where did I get wrong? Thanks! 回答1: You can be committing one or more of many mistakes: Arrays not defined as Variant (Most worksheetfunctions won't work if

Array multiplication and matrix inversion with VBA

邮差的信 提交于 2021-02-18 19:34:13
问题 I am trying to do some calculations with arrays. e.g. I want to solve Ax=y , so I use the following code to do so, where A is a square matrix and y is a col. vector. In VBA, A is an array with two dimension and y is one with one dimension. However, this code does not work... x = WorksheetFunction.MMult(WorksheetFunction.MInverse(A), y) Where did I get wrong? Thanks! 回答1: You can be committing one or more of many mistakes: Arrays not defined as Variant (Most worksheetfunctions won't work if