access-vba

MS Access OpenForm acDialog option does not seem to work

爷,独闯天下 提交于 2020-01-03 04:51:19
问题 This DoCmd.OpenForm fnew, , , , , acDialog Doesn't seem to stop code execution for some reason. Is it because I'm calling the function that has this method from another function and that is messing it up? E.g. func1 <code> Call func2 <func2 code> DoCmd.OpenForm fnew, , , , , acDialog <back to func1 code that executes even though i dont want it to until the form closes> 回答1: With acDialog as the OpenForm WindowMode parameter, your calling code should not continue until the form is closed. It

Access VBA - Launch password protected database and close existing one

南笙酒味 提交于 2020-01-03 03:02:11
问题 I am trying to set up a "Launcher" database which contains vba code that will open a second database which is password protected. (I can then convert the launcher db to accde so the VBA containing the password cannot be read) I have the following code so far... Private Sub Form_Load() Dim acc As Access.Application Dim db As DAO.Database Dim strDbName As String strDbName = "C:\database Folder\secureDB.accdb" Set acc = New Access.Application acc.Visible = True Set db = acc.DBEngine.OpenDatabase

Timer looping in vba (Access)

点点圈 提交于 2020-01-03 02:45:09
问题 I'm trying to configure a timer to run every 3 minutes in VBA, to loop through my Access database table and validate data. I'm stuck at the point of starting the timer. I wrote this mini script to test the timer: Function JobNameValidate() MsgBox ("Hello") 'callAgain.OnTimer End Function Function callAgain() callAgain.TimerInterval = 300000 Forms("HiddenForm1").OnTimer JobNameValidate End Function It loops fine, however it loops instantly, regardless of the TimerInterval put in. I couldn't

Open MS Access and Fire Macro using MS Outlook

旧时模样 提交于 2020-01-03 02:21:12
问题 I did a bit of research and I think the best way to auto-fire a Macro is to use the AutoExec method in Access. I believe the script below will do the job. Option Compare Database '------------------------------------------------------------ ' AutoExec ' '------------------------------------------------------------ Function AutoExec() On Error GoTo AutoExec_Err DoCmd.RunCommand acCmdWindowHide MsgBox "Welcome to the client billing application!", vbOKOnly, "Welcome" DoCmd.OpenTable "Orders",

Using Alias keyword to declare a function in VBA

假装没事ソ 提交于 2020-01-02 15:57:54
问题 I have VBA MS Access form code, where I type the following function declaration: Public Declare Function GetUserName Lib "advapi32.dll" () Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long However I'm getting an error on Alias . Do I have to add some references in order to use this? 回答1: No, there are no special libraries are required to use Alias ; this is all built into the language. But your declaration is wrong. You have an extra set of parentheses placed just before

Getting attribute values in VBA

一世执手 提交于 2020-01-02 08:24:55
问题 I need to make a VBA file that will read a webpage and return the value of the SRC attribute of the IMG tag. I wasn't able to make the last step work. Can you guys help me? <html> <body> <img src="image.jpg"> </body> </html> ===Edit=== I managed to return the attribute object. Now I need to return its value Option Compare Database Sub AcessaPagina() Dim ie As InternetExplorer Dim test As String Dim obj As Object Set ie = New InternetExplorer ie.Navigate "http://www.google.com.br" MsgBox ie

Access 2013 VBA - Setting New Click Event for Controls

霸气de小男生 提交于 2020-01-02 04:35:05
问题 I have searched everywhere for this, and it seems like a simple fix, but I can't seem to find the solution. I have several Rectangle controls in my Access 2013 form, and I'm creating an OnClick event that handles them all. I've worked on a few different methods, and I think I found the simplest/cleanest way to do it. I put the controls in a collection and change the OnClick event for each control. Here's my problem: Access opens the form and recognizes that I changed the event for the control

Exporting Charts of Access to Image Format?

浪子不回头ぞ 提交于 2020-01-01 16:33:33
问题 I have created a chart in Access forms and exported it in Image Format. It's easily done, but the problem comes when after it, when I close the Form, It Shows a Pop-up message. "The operation on the Chart object failed. The OLE server may not be registered. To register the OLE server, reinstall it. " Then I have done some change and the Code looks Like: Private Sub Command1_Click() Dim grpApp As Graph.Chart Set grpApp = Me.Graph1.Object grpApp.Export "C:\Graph1.jpg", "JPEG" Me.Graph1.Enabled

OpenArgs is Null error

若如初见. 提交于 2020-01-01 04:59:09
问题 I am using the OpenArgs parameter to send a value when using DoCmd.OpenForm : DoCmd.OpenForm "frmSetOther", acNormal, , , acFormAdd, acDialog, "value" I then use Me.OpenArgs inside the opened form to grab the value . It sometimes sends a Null value instead of the original string. What is wrong? 回答1: A very interesting alternative to this "openArgs" argument is to use the .properties collection of the currentProject.allforms("myFormName") object. When you need to pass a value to a form (such

import tab-delimited txt into Access table using VBA

拥有回忆 提交于 2020-01-01 03:24:24
问题 I am trying to import a tab-delimited txt file into an Access table using VBA. In my code, I want to insert it into a table that has not yet been created. Here is what I tried doing. Note - I was able to make this work with a CSV, and without including this: DataType:=xlDelimited, Tab:=True Sub InsertData() 'import CSV into temp table DoCmd.TransferText TransferType:=acLinkDelim, TableName:="tbl_TEMP", _ FileName:=FileNameVariable, HasFieldNames:=True, DataType:=xlDelimited, Tab:=True End Sub