access-vba

How to get the affected rows in VBA ADO Execute?

 ̄綄美尐妖づ 提交于 2019-12-19 19:13:29
问题 The following code errors on the MsgBox cn.RecordsAffected line with: Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another. How can I successfully get the affected number of rows? This is for an Access 2003 project. I'd prefer to keep it in 2003 format, so if there's another way to do this, that would be great. I'd like to not have to upgrade the entire project for the sake of this 1 function. Private Sub Command21_Click() On Error GoTo Err1: Dim

MS Access VBA - display dynamically built SQL results in datasheet subform

拥有回忆 提交于 2019-12-19 16:36:18
问题 I have several years experience with VBA in MS Office applications (for automation and ETL processes) but have not had the need to mess with Forms in MS Access until recently. I'm laying out the design for some simple data extraction forms for a database I have designed and am hung up on what seems to be a simple task. Objective: I need a datasheet subform to display the records returned from a dynamically built SQL statement from controls on the main form. On my main form, I have a button

Is there an “On Close” event for MS Access VBA?

浪子不回头ぞ 提交于 2019-12-19 14:19:13
问题 Am trying to perform some specific actions, before closing the access database (whenever the database is closed by the user). I know we can use Auto_Close function in Excel VBA to force events before closing the book. Is there a similar function in MS Access VBA? If so, an example would be appreciated. Please let me know if you need more information. Thank you. 回答1: No, there isn't an application quit or close event for MS Access. The common approach seems to be having a hidden form open at

Is there an “On Close” event for MS Access VBA?

扶醉桌前 提交于 2019-12-19 14:18:09
问题 Am trying to perform some specific actions, before closing the access database (whenever the database is closed by the user). I know we can use Auto_Close function in Excel VBA to force events before closing the book. Is there a similar function in MS Access VBA? If so, an example would be appreciated. Please let me know if you need more information. Thank you. 回答1: No, there isn't an application quit or close event for MS Access. The common approach seems to be having a hidden form open at

How to Autofill Textboxes on a Form using a Loop?

混江龙づ霸主 提交于 2019-12-19 10:52:46
问题 So I have a table that has a list of totals im trying to display on a form, I have 10 totals I need to get from the totals table and display in 10 textboxes on the form. The 10 textboxes are "A1, A2, A3..." and its using DLookup to find the ID field number. It seems like its a syntax issue with Me.TEXTX & X1.Value though I'm not sure how else I can type it. Hope this makes sense. Thanks! Private Sub UPDATETOTALS() Dim FORMX As String FORMX = "GRID" Dim TEXTX As String TEXTX = "A" Dim

Loop through all unbound controls on a form and clear data

隐身守侯 提交于 2019-12-19 09:39:38
问题 I would like to loop through all UNBOUND controls on my form and clear their data or reset their values. I have textboxes, comboboxes and checkboxes. Every time I try something like this: Dim ctl As Control For Each ctl In Me.Controls If IsNull(ctl.ControlSource) Then ctl.Value = Nothing End If Next ctl I get a runtime error saying: 438 This object doesn't support this property or method. 回答1: That code loops through every control in the form's Controls collection. The collection includes

Is it possible to raise events on a subform's form, when that subform is bound to a table?

旧时模样 提交于 2019-12-19 06:59:22
问题 I've got a form with a subform which is bound to a temporary table. The temporary table contains the result of a pivot, but I'd like users to be able to edit that pivot and then push the changes to the source table. To do this, I'd like to fire events on AfterInsert , AfterUpdate and Delete so I can act on changes. As I understand it, the subform's form property refers to a temporary datasheet form when the subform is bound to a table. However, I can't get this temporary form to raise any

How to use sftp from within an MS Access database module?

这一生的挚爱 提交于 2019-12-19 03:18:27
问题 I have a requirement to create a simple database in Access to collect some user data that will be loaded into another database for further reporting. There will be a module in the Access db that when invoked by the user (probably by clicking a button) will output a query to a delimited file. The user also needs a mechanism (for example a form with a button) to easily transfer the file to a remote server, using sftp. Does anyone have an idea of how to accomplish this? 回答1: You can simply write

In Memory, Stand-Alone, Disconnected ADO Recordset

孤街醉人 提交于 2019-12-19 03:16:41
问题 I'm running this code on my datasheet subform when my form loads and I'm not getting any error messages or code breaks. My debug.print shows that the Recordset rs is filled with 2131 records like it should be, but my form shows a single row with #Name? in every field. The control source properties on my controls most certainly do match the field names I have listed above. RS is a form level variable and I'm not closing it or setting it to nothing until the form closes. Any idea what am I

In Memory, Stand-Alone, Disconnected ADO Recordset

好久不见. 提交于 2019-12-19 03:15:03
问题 I'm running this code on my datasheet subform when my form loads and I'm not getting any error messages or code breaks. My debug.print shows that the Recordset rs is filled with 2131 records like it should be, but my form shows a single row with #Name? in every field. The control source properties on my controls most certainly do match the field names I have listed above. RS is a form level variable and I'm not closing it or setting it to nothing until the form closes. Any idea what am I