vba

Get ID of Last Inserted Record - Access DAO, ODBC, SQL Server 2008 Identity Field

三世轮回 提交于 2021-02-07 19:46:00
问题 It's a very common question but I'm having trouble getting the ID of the last inserted record. I'm using DAO with ODBC linked tables to duplicate a record and it's child records. My tables are in SQL Server 2008 and have Identity fields for ID fields. Here's what I've tried so far. My first bit of code here results in error 3167, Record is Deleted. If I do a debug.Print the recordset actually contains 3 records. Dim r as DAO.Recordset, db as DAO.Database Set db = CurrentDb Set r = db

Get ID of Last Inserted Record - Access DAO, ODBC, SQL Server 2008 Identity Field

安稳与你 提交于 2021-02-07 19:45:06
问题 It's a very common question but I'm having trouble getting the ID of the last inserted record. I'm using DAO with ODBC linked tables to duplicate a record and it's child records. My tables are in SQL Server 2008 and have Identity fields for ID fields. Here's what I've tried so far. My first bit of code here results in error 3167, Record is Deleted. If I do a debug.Print the recordset actually contains 3 records. Dim r as DAO.Recordset, db as DAO.Database Set db = CurrentDb Set r = db

Creating a new folder in Sharepoint using VBA

泪湿孤枕 提交于 2021-02-07 18:26:46
问题 I'm trying to automatically save workbooks using VBA to a Sharepoint folder- which needs to be created first. Code I have below works ONLY for saving the file. The MkDir function returns a Run-time error 76: Path not found. I'm at a loss what causes this error, because the path before /txt DOES exist and I do have the right permissions to add new folders by hand. I have also tried replacing the current path with \ instead of /, but other than making the code significantly slower this has no

“Flatten” multiple rows containing different data but with a common reference into a single row

大憨熊 提交于 2021-02-07 17:30:24
问题 I've tried searching Stackoverflow and Google for an answer to this but haven't found it yet. I think part of my problem is I'm not sure what the keyword(s) for what I'm trying to do would be. My data looks something like this: ID Var1 Var2 Name 01 0001 0002 Bill 01 0001 0002 Jim 01 0001 0002 Sally 02 0003 0004 Sam 02 0003 0004 Kyle You'll see that I have multiple rows with the same ID and same Var1 and Var2 but each row has a unique name. I want to "flatten" the rows so there is only a

“Flatten” multiple rows containing different data but with a common reference into a single row

风流意气都作罢 提交于 2021-02-07 17:30:07
问题 I've tried searching Stackoverflow and Google for an answer to this but haven't found it yet. I think part of my problem is I'm not sure what the keyword(s) for what I'm trying to do would be. My data looks something like this: ID Var1 Var2 Name 01 0001 0002 Bill 01 0001 0002 Jim 01 0001 0002 Sally 02 0003 0004 Sam 02 0003 0004 Kyle You'll see that I have multiple rows with the same ID and same Var1 and Var2 but each row has a unique name. I want to "flatten" the rows so there is only a

“Flatten” multiple rows containing different data but with a common reference into a single row

爷,独闯天下 提交于 2021-02-07 17:28:16
问题 I've tried searching Stackoverflow and Google for an answer to this but haven't found it yet. I think part of my problem is I'm not sure what the keyword(s) for what I'm trying to do would be. My data looks something like this: ID Var1 Var2 Name 01 0001 0002 Bill 01 0001 0002 Jim 01 0001 0002 Sally 02 0003 0004 Sam 02 0003 0004 Kyle You'll see that I have multiple rows with the same ID and same Var1 and Var2 but each row has a unique name. I want to "flatten" the rows so there is only a

Reordering Multiple Columns in Excel VBA

落爺英雄遲暮 提交于 2021-02-07 17:26:57
问题 Is there a way to create a 'permutation' macro where you input a set of columns (A....Z) and it gives a chosen alternate ordering (e.g. (B,A,E,D,C,...,Z))? I imagine this is something that has been done before but it is surprisingly hard to find any precedent. Initially I was thinking of copying / pasting using Range().Copy / .Paste in a tedious way or similarly with Columns , that is: Columns("C:C").Insert Shift:=xlToRight Columns("D:D").Cut Columns("A:A").Insert Shift:=xlToRight Columns("G

Add checkboxes to UserForm based on cell value

送分小仙女□ 提交于 2021-02-07 17:24:17
问题 I'm very new to VBA, just 3 days... but i found it very useful and easy to use, but now i'm facing a problem. I need to make a UserForm with different Checkboxes, but i need them to be added automatically based on the information used in one of the columns of a Sheet. I believe i can use the For .. Each .. Next but i really don't know how to fill the Checkboxes. This is the only solution that i have right now, but i can't make differents Checkboxes, only one. For Each rCell In Range("B1:B" &

Set Excel Range Formatting With Array

六月ゝ 毕业季﹏ 提交于 2021-02-07 14:52:17
问题 I have, in the past, used a variant array to populate a range of multiple Excel cells. I'm wondering, is there a way to do the same thing with cell formatting? I'd rather not go cell by cell, and it'd be nice to minimize the number of calls to get an Excel range... 回答1: @ExcelHero has pointed out to me how to get this done, so here's how. If your range is horizontal, then just feed it an array built of Format strings: [a1:c1].NumberFormat = Array("hh:mm", "General", "$#,##0.00") If your range

Set Excel Range Formatting With Array

半腔热情 提交于 2021-02-07 14:52:12
问题 I have, in the past, used a variant array to populate a range of multiple Excel cells. I'm wondering, is there a way to do the same thing with cell formatting? I'd rather not go cell by cell, and it'd be nice to minimize the number of calls to get an Excel range... 回答1: @ExcelHero has pointed out to me how to get this done, so here's how. If your range is horizontal, then just feed it an array built of Format strings: [a1:c1].NumberFormat = Array("hh:mm", "General", "$#,##0.00") If your range