access-vba

MS Access 2003 - Is there a way to programmatically define the data for a chart?

余生长醉 提交于 2019-12-14 03:48:53
问题 So I have some VBA for taking charts built with the Form's Chart Wizard, and automatically inserting it into PowerPoint Presentation slides. I use those chart-forms as sub forms within a larger forms that has parameters the user can select to determine what is on the chart. The idea is that the user can determine the parameter, build the chart to his/her liking, and click a button and have it in a ppt slide with the company's background template, blah blah blah..... So it works, though it is

Run VBA for each record in a form

余生长醉 提交于 2019-12-14 03:35:09
问题 Given a form which continuously displays certain text boxes for a each record of a table, I'd like a VBA sub to be executed after all text boxes for each record have been (automatically, not via VBA) populated with data from the current record. So the idealized order of execution would be: fetch next record from table distribute values into text boxes and draw execute VBA fetch next record from table How can I achieve this? Note: The form is "continuous" (I don't know how to say this in

Get previous month's data alongside current month

风格不统一 提交于 2019-12-14 03:05:25
问题 I have a table that roughly looks like this Transaction Date Gain/Loss 15464 7/31/2018 $500 15464 6/30/2018 -$200 59872 7/31/2018 $1000 59872 6/30/2018 $2500 How can i add another column that calculates the difference between the current month's gain/loss and the previous month's for each specific transaction number? i.e. Transaction Date Gain/Loss Change in Gain/Loss 15464 7/31/2018 $500 $700 15464 6/30/2018 -$200 -$200 59872 7/31/2018 $1000 -$1500 59872 6/30/2018 $2500 $2500 回答1: I think

How to select only numbers from a text field

折月煮酒 提交于 2019-12-14 02:22:33
问题 How can I pull only the number from a field and put that value into its own field? For example, if a field1 contains a value of "Name(1234U)". I need an SQL or VBA way to scan that field and pull the number out. So field2 will equal "1234". Any ideas? 回答1: It is possible that this or a variation may suit: SELECT t.Field1, Mid([Field1],InStr([field1],"(")+1,4) AS Stripped FROM TheTable As t For example: UPDATE TheTable AS t SET [field2] = Mid([Field1],InStr([field1],"(")+1,4); EDIT re comment

MS Access - Data Type Mismatch

孤人 提交于 2019-12-14 01:55:10
问题 I have the follow VBA code and it returns a ' data type mismatch in criteria expression ' while executing. I cannot seem to find out why it is giving me this error. Can anybody help me? VBA: Public Function GezaagdeOmzet(ByVal TotaalPrijs As Double, ByVal AantalArtiklesPerOrder As Double, ByVal TotaalArtiklesPerOrder As Double, ByVal AantalArtiklesVerwijderedUitZaaglijst As Double) As Double Dim result As Double On Error GoTo ErrHandler If IsNumeric(TotaalPrijs) = False Then MsgBox (

Object variable or With block variable not set Access vba [duplicate]

核能气质少年 提交于 2019-12-13 22:24:17
问题 This question already has answers here : Vba Access error 91 (2 answers) Closed 2 years ago . I'm working with a couple tables, CTOL and CTOL_Asbuilt in Access. I'm trying to run a query to join these two tables together using VBA code. I ran the query in Access and it works. I'm using DAO for the database library to retrieve data from the local Access database (code is in the same database project as the database), and I'm new to VBA Access scripting. SELECT CTOL.ID, CTOL.BOM_PART_NAME, CTOL

How to get the last record id of a form?

a 夏天 提交于 2019-12-13 19:18:57
问题 I currently have a form in access. What I want to do is get the value of the last record added. For example, if i have 10 records, I want to get the value "10", because this is the id of the added last record. I am trying to run a query with the function last id inserted() but it is not working. This the code I am using : Dim lastID As Integer Query = "select last_insert_id()" lastID = Query MsgBox (lastID) What am I missing? 回答1: There is a function DMax that will grab the highest number.

Insert Into Select From linked table

孤人 提交于 2019-12-13 19:02:01
问题 I am trying something that has been done hundreds of times - except my code does not compile. Using this as a reference How to do INSERT into a table records extracted from another table I came up with the following sub, that is supposed to clear a table and refill it from another linked table (The idea is to liberate the linked table so it doesn't have a .laccdg file in its name for long) Private Sub Form_Open(Cancel As Integer) Dim rsDocs As Recordset Dim sqlQuery As String DoCmd.RunSQL

Access VBA Pass a MultiDimensional Array in a function

偶尔善良 提交于 2019-12-13 18:54:23
问题 Access 2013 32 bit: Win 7 64bit Tried: Is it possible to pass a multidimensional array as a parameter in EXCEL VBA? to no avail (If you can answer this you can probably answer that, but they're a little different) Sub CreateArray() Dim myArray(1 to 10, 1 to 5) 'Code that assigns values to (1 to 10, 1 to 4) myArray() = CalculateLastColofArray(myArray()) 'Do stuff with full array End sub Function CalculateLastColofArray(calcArray) For i = LBound(calcArray()) to UBound(calcArray()) calcArray(i,5

Running an update query to a memo field

佐手、 提交于 2019-12-13 18:16:45
问题 This may be a simple one (whether it is possible or not).. I have two tables which are identical with a set of records. I need to find the best way that when one of the memo fields is modified, that the modifications get carried to the identical record on the corrisponding identical table. In many cases the field may have hundreds of words.. The only way that i know how to potentially do this is using an update query, but i am wondering if the test within is really large, will it break? Or is