access-vba

horizontalAlignment doesn't work with xlFill

纵然是瞬间 提交于 2019-12-24 10:47:39
问题 I am trying to make my column in excel fit into the column size that I give it, I am trying to use the property horizontalAlignment to do this. I can get it working with xlCenter, but I need to do xlFill but there isn't a value for xlFill. With objExcelAssist.worksheet.columns("N:N") .horizontalAlignment = xlCenter End With What I have tried: With objExcelAssist.worksheet.columns("N:N") .horizontalAlignment = xlFill End With With objExcelAssist.worksheet.columns("N:N") .horizontalAlignment =

Unable to remove master -> child subform links in microsoft access 2003

走远了吗. 提交于 2019-12-24 10:45:33
问题 I am having an issue removing the master -> child link fields in an access subreport data form. I have tried every avenue to remove them, using the properties window of the subreport as well as the link wizard. I have also deleted the subreport from the database and then gone as far as re-importing the existing objects into a new access instance. As soon as I re-added the subform back in and name it the same name the link fields show back up. Something is apparently corrupt, but I have run

Compile Error: Expected function or variable in VBA for access

ぐ巨炮叔叔 提交于 2019-12-24 10:44:10
问题 I know near nothing about VBA, but I'm trying to modify an application to connect to a MySQL Database. The following code produces a Compile error at rstProjets.Open and I can't seem to find why. Public mysqlConn As ADODB.Connection Private Sub cmdUpdate_Click() Dim rstProjets As ADODB.Recordset ConnectMySQL Set rstProjets = rstProjets.Open("SELECT * FROM subventions LIMIT 5", mysqlConn) With rstProjets If Not .EOF And Not .BOF Then .MoveFirst Do While Not .EOF MsgBox "Subventions:" &

Rookie SQL inside of VB question - MSAccess 2003

旧时模样 提交于 2019-12-24 09:49:02
问题 Hey guys, can anyone help me with a simple question. I have this SQL statement below in a sub in VB within access from a button click, and I am new to this. Here is what I typed: Private Sub Command0_Click() Dim rs As Recordset Dim sql As String Dim db As Database Set db = CurrentDb sql = "SELECT * FROM Transactions" Set rs = db.OpenRecordset(sql) Do Until rs.EOF rs.MoveNext Loop If Not rs.EOF Then MsgBox "test" End If End Sub Ok, so how do I populate this?? Essentially I am justing starting

How to add file name when importing multiple Excel files to one Access table

对着背影说爱祢 提交于 2019-12-24 09:48:27
问题 I am using Access VBA to import multiple Excel files into my Access database. This will be a monthly process with 20-50 files and 10-60K records. I need to include an "Application name" that isn't included within the spreadsheet file itself, but is in its file name. Rather than manually adding the application name to the Excel file I'd like to have it added via my VBA code. I'm not proficient with Access and have pieced most of this together from searches on how to complete. This "works" but

Finding the VBIDE.Reference.Name of object libraries vba

為{幸葍}努か 提交于 2019-12-24 09:48:21
问题 I've found how to add a reference programmatically with VBA, This explains how to add object references programmatically using the name of the Library, with the example "VBScript_RefExp_55". My question is how do I find this reference name to use in this code for different object libraries? Such as the PowerPoint Library for example? 回答1: I use this to get the info on my references : Private Sub ListProjectReferencesList() Dim i As Long Dim VBProj As Object 'VBIDE.VBProject Dim VBComp As

Form is ignoring the code in OnOpen event

▼魔方 西西 提交于 2019-12-24 09:39:39
问题 Have a new form that contains controls and is linked to a table in SQL Server. Have code that relinks the table on open, and that code works in 5 other apps, but not this one. Here is the code: Dim tdf As DAO.TableDef For Each tdf In CurrentDb.TableDefs ' check if table is a linked table If Len(tdf.Connect) > 0 Then tdf.Connect = "Connect String" tdf.RefreshLink End If Next I had the form set up in options to open when the app is activated, but it ask for the password which I have in the

VBA code that changes the background color of a form after update

拈花ヽ惹草 提交于 2019-12-24 09:38:42
问题 I need some code that when a check box is unchecked it will change the background color of my form and return it back to its original color when checked. The code i have for the check box currently locks a combo box when a value is chosen. Example below Private Sub AccessKeyNo_AfterUpdate() If MsgBox("Do you want to assign Access Key " & Me.AccessKeyNo & "?", _ vbYesNo) = vbYes Then Me.GuestAccessKeyID = Me.AccessKeyNo If Me.Dirty Then Me.Dirty = False Me.AccessKeyNo.Requery Me.AccessKeyNo =

Audit Track a form

 ̄綄美尐妖づ 提交于 2019-12-24 08:56:05
问题 I am setting up a Audit Tracking system for the forms in my database. I am following the example from Susan Harkins Here My code works for my form customers which is based off the customers table. Here is my code: Const cDQ As String = """" Sub AuditTrail(frm As Form, recordid As Control) 'Track changes to data. 'recordid identifies the pk field's corresponding 'control in frm, in order to id record. Dim ctl As Control Dim varBefore As Variant Dim varAfter As Variant Dim strControlName As

Execute method does not consistently execute all command text

元气小坏坏 提交于 2019-12-24 08:31:02
问题 I have below procedure to execute multiple command text to update an Access Table from Excel. Private Sub LogToDBMult(ParamArray sqlstr()) Dim con As Object, i As Integer Set con = getCon() With con For i = LBound(sqlstr) To UBound(sqlstr) If sqlstr(i) <> "" Then .Execute sqlstr(i) Sleep 1000 '/* this is an API call */ DoEvents End If Next .Close Set con = Nothing End With End Sub Private Function getCon() As Object Dim oCon As Object Dim sCon As String sCon = "Provider=Microsoft.ACE.OLEDB.12