access-vba

Recommended way to read and write .ini files in VBA

孤者浪人 提交于 2020-03-17 07:14:09
问题 Are any methods available in VBA to read and write INI files? I know I could use; Open "C:\test.ini" For Input As #1 ...and parse the data. Instead I am trying to see what tools are already available. I know in C# you can do... using INI; INIFile ini = new INIFile("C:\test.ini"); Is there an equivalent for VBA? I am attempting this in MS Access 2003 VBA. 回答1: Here are some code snippets that we use, it should help you to get the idea. These routines use the API calls. Two functions are

Access VBA: Shell command broken in one particular database

半腔热情 提交于 2020-03-05 05:19:24
问题 I have two Access databases that I'm opening on the same computer. In one, running this in the immediate window works as expected (opens Notepad): Shell "notepad.exe" In the other, I get this error instead: Run-time error '5': Invalid procedure call or argument I have not been able to come up with any shell command that will run successfully in that second database. No matter what, I get that error. What is going on here? Could there be a security setting coming into play? Or perhaps one is

VBA: Event for triggered Events

风格不统一 提交于 2020-02-16 09:58:04
问题 I am looking to see if there is an Events trigger for well... Events. I'm making an idle timeout function and the thought of having to call my function for every procedure seems a bit unnecessary. More specifically OnClick events. I do have an DoEvents loop that is constantly going. I there a way to find what is being triggered via DoEvents ? Or DoEvents Returns what Event is running. 回答1: That would be WithEvents - poorly documented but quite handy. Recently, I wrote an article on a

Inline SQL statement returning only duplicate first record in recordset

最后都变了- 提交于 2020-02-07 17:18:18
问题 I have a table named Employees with a field named EmployeeID. In a separate table, I have a separate master table of employees named Master with a field named EmployeeStatus. I am trying to validate all employees who have been terminated from the company are not listed in the Employees table. However, current code I am using below is returning duplicate of the first record in the master table of employees. The value of record count property of the recordset object matches what I expect, the

Query for getting value from another record in same table and filter by difference greater than a gap threshold

微笑、不失礼 提交于 2020-01-26 20:54:46
问题 I have data imported into a temporary table in MSAccess which looks like this: to which I have added the "Gap" and "Previous/Current" columns that I need to calculate using an SQL Query. The "Gap Threshold" is User input or PARAMETER supplied to Query and for e.g. is 300. The GlobalID groups ItemID's whereas each ItemID is unique number. What i want to do is calculate the GAP (GAP = TEMPORARY_1![VERSION DATE] - TEMPORARY![VERSION DATE]) between ItemID's of similar GlobalID's and identify the

Trying to execute a SQL statement from VBA to an Access database, getting a syntax error with the INSERT INTO statement [closed]

点点圈 提交于 2020-01-26 04:00:08
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last month . This is the code: sqlStr = "INSERT INTO Students (ID, Last Name, First Name, E-mail Address, Student ID, Level, Date of Birth, Home Phone, Address, City, State/Province) VALUES ('" & ID.Value & "','" & lastName.Value & "','" & firstName.Value & "','" & email.Value & "','" & studentID.Value & "','" &

How to find the the primary key sequence and the max of primary key

房东的猫 提交于 2020-01-25 10:08:45
问题 I know this question is kind of silly, I need to run these queries to see if the values are out of sync, but I get an error like 'relation does not exist': SELECT MAX(the_primary_key) FROM the_table; SELECT nextval('the_primary_key_sequence'); I have a table named "Audit" with the primary key column 'auditID'. When I run the first query I got the result: SELECT MAX('auditID') FROM "Audit"; max --------- auditID (1 row) but the max should be more than 10000. Then I run the second query and I

How to find the the primary key sequence and the max of primary key

风格不统一 提交于 2020-01-25 10:05:43
问题 I know this question is kind of silly, I need to run these queries to see if the values are out of sync, but I get an error like 'relation does not exist': SELECT MAX(the_primary_key) FROM the_table; SELECT nextval('the_primary_key_sequence'); I have a table named "Audit" with the primary key column 'auditID'. When I run the first query I got the result: SELECT MAX('auditID') FROM "Audit"; max --------- auditID (1 row) but the max should be more than 10000. Then I run the second query and I

How to find the the primary key sequence and the max of primary key

吃可爱长大的小学妹 提交于 2020-01-25 10:05:21
问题 I know this question is kind of silly, I need to run these queries to see if the values are out of sync, but I get an error like 'relation does not exist': SELECT MAX(the_primary_key) FROM the_table; SELECT nextval('the_primary_key_sequence'); I have a table named "Audit" with the primary key column 'auditID'. When I run the first query I got the result: SELECT MAX('auditID') FROM "Audit"; max --------- auditID (1 row) but the max should be more than 10000. Then I run the second query and I

Copying data from a MS Access form into Excel

泪湿孤枕 提交于 2020-01-25 09:19:06
问题 I have code that takes fields from a MS Access form and copies the data into a saved Excel file. The first record in Access in imported to Excel with a range of A2:I2. The second record in Access is imported to Excel with a range of A3:I3, and so on.... What currently happens now is if I close my form in Access and open it back up, and say I already had two records imported into this same Excel file, and now I want to add a third record, it will start over at the first row (A2:I2) and write