Modules & VBA :: Write A More Complex Macro That Will Start Another Macro At Preset Time
Dec 8, 2013
I am trying to write a more complex macro that will start another macro at a preset time, however I am getting stopped at the first hurdle - getting a macro to run another macro.
Here is the code i am using at the moment, all I want to do currently is click the first button, then get the second macro to execute. But no luck, getting error 2157 "cannot find the procedure"
I would like to have a macro run at a set time each day. I hoped to use .ontime but apparently that doesn't exist in access.
The macro must run at 10:00am each day, the db will be open from 8:30am until 16:30pm so no problem from that point of view +/- a few mins when the staff arrive.
I have a button that runs a macro to delete records in 12 tables. I want to create a message box before that macro runs warning that you are deleting records in 12 tables and are your sure you want to run the macro.
I need a message box with an ok and cancel button. Where do I put the msgbox funtion in this code?
Thanks !!
This is my code:
Private Sub cmdRunDeleteMacro_Click() On Error GoTo Err_cmdRunDeleteMacro_Click
I know that I can startup MS-Access manually and bypass the startup options, including any macro that is set to run automatically, by holding the Shift key down when launching the application. I have:
Code: Public Sub AccessStuff() Dim myaccess As New Access.Application myaccess.OpenCurrentDatabase(" orfs006slsops_repts\_RS DevSOPSOP.MDB") Dim db = myaccess.CurrentDb() End Sub
which works nicely and opens the database just fine. However, this mdb has a startup macro defined in it. I can't hold down the Shift key since I'm doing this from a program. In this case, how can I bypass the startup macro?
I'd like to use a macro to display only those items which stay as a group in "Old Project Code" (black font) and filter out those which are singles in "Old Project Code" (red font) as shown below extracted out from a worksheet called "Project" in Excel.
1. The color wasn't there in original sheet. It is here only for demo purpose. 2. Data are changing dynamically, so need a macro in place to catch a snapshot at the time of macro is firing.
how to get macro properties using vba? I've attempted something similar to the below to try and divine macro properties:
Code: Sub MacroDiscovery() Dim mcr As AccessObject Dim prop As AccessObjectProperty For Each mcr In CurrentProject.AllMacros Debug.Print mcr.Name For Each prop In mcr.Properties Debug.Print prop.Name Debug.Print prop.Value Next Next End Sub
Nothing comes up except the macro names. In my database, I have an AutoExec macro that I have manually added a description to; "This macro auto-executes when the database is opened by virtue of it's name." I can view the description by right-clicking on the macro and choosing 'Object Properties'.
Background:I am attempting to make a universal Access Database documenter for the many, many homemade databases on our network. I'm only interested in certain pieces of information and I would like to make a report to view the information how I want to view it. Thus, I don't care for the built-in documenter--I want to do it my way.
I have inserted a function via a module at the beginning of a Macro using the RunCode action:
Function Msgbox_Yes_No() Dim Response As Integer Response = MsgBox(prompt:="Select 'Yes' or 'No'.", Buttons:=vbYesNo) If Response <> vbYes Then End If End Function
However, it doesnt stop the macro from continuing on its way to delete a load of records if the user chooses no.
I have 2 forms and a macro in Form1 which runs throught every record to update the records, however.I would like to run this macro from the main form (Form2)
I'm working in 2003 (still) and have a macro to print the selected form the user has on their screen. I need this same macro to also print a PDF in a particular network folder or just exit if the PDF doesn't exist. I've tried RunSQL with "PrintDoc [Link2PDF]" as the argument. I've tried RunApp with "Acro Rd32.exe /t [Link2PDF]" as the argument but neither one works. The RunApp line will open the Adobe reader but nothing more.
I have an open form with buttons to open other forms and use an If statement to position them an example is below.
Code: Private Sub Command31_Click() DoCmd.OpenForm "Opener", acNormal If Me.Frame54 = 1 Then DoCmd.MoveSize 2500, 1000 ElseIf Me.Frame54 = 2 Then DoCmd.MoveSize 25500, 1000 End If End Sub
This works perfectly, however I need to put similar code as a line in a macro and cannot seem to link it.
Code: Public Function totalmove() If Forms.Scan_Data.Frame54 = 1 Then DoCmd.MoveSize 2500, 1000 ElseIf Forms.Scan_Data.Frame54 = 2 Then DoCmd.MoveSize 24000, 1000 End If End Function
I get Error 438 object doesn't support this property or method...
I have two tables in my Access database, their fields are exactly the same (for now). One table is called Uncheched. The other one is called Checked. So what is need is a macro that takes selected records in table Unchecked and copies them to the end of table Checked. Actually CUTS from Unchecked and PASTES to the end of Checked table.
Sub MoveRecords() DoCmd.RunCommand acCmdCut DoCmd.OpenTable "tblChecked", acNormal, acEdit DoCmd.GoToRecord , , acLast DoCmd.RunCommand acCmdPaste End Sub
I have a table it contains a list of opening and closing values along with a date and a couple control fields. What I would like to do is duplicate a few fields from records that meet a criteria onto the same table. After that is done there will be a few updates on the new records. Looking at it, it would be: 'duplicate' where field2 <> 0 and field5 = No and field6 = Yes. All other fields on the newly created records would be their default values.
I have built an access application that contains a set of buttons along the top of every form that serve as navigation.* These buttons each perform the same function on every form they are on. (menu opens the main menu, etc) I have database macros to assign each button the same function but I still have to go through each form and manually assign them. I was wondering if it was possible to define a public function that on db open will look for all buttons with a certain name and assign them the macro. (so all buttons called cmdmainmenu will have the OpenMainMenu macro assigned and so on).Before you go there, I have already tried the navigation form and set all forms as subforms.
Actually I need to select printer before printing report. That's why I need to call printer dialog to select printer using "PrintObject" in macro. But it's print the form not report. I need to print a specific report.
I have contract notes files in .xls format towards sale of equity shares from the brokerages. I have to do some editing in these files like deleting some rows, adjusting width of columns and inserting date of contract.
a) Contract-A.xls shows original file. b) Contract-B.xls shows modified file c) VBA macro code used for deleting rows and modifying column width is shown in modify_contractnotes.xlsm file. d) Presently I open the file and copy and paste the contents on the macro-enabled workbook sheet . After macro operation I transfer back the contents by copy and paste to a master file(Contract-C.xlsx) and clear the contents in the macro enabled workbook to make it ready for another operation. e) It is time consuming process for around 60 files per month. f)After this operation I run RDBMerge add-in to consolidate and normalize all these files in a directory. RDBMerge smoothened out merged cells also.
Is it possible to have a macro-enabled workbook open all the time and the contract files be opened one after other and macro contained in macro enabled workbook by modifying its code suitably operate on these contract files.
Files are attached in modify_contractnotes zipped folder.
Is it possible to have a macro button to pass query results to a listbox? I have a database where I have some fields with dates. What I need to do is to show a list of all cases that have a start date (and also the end date). So I will have 2 buttons, one that says "show started cases" and second one "show closed cases". If I press the first button, it will run a query and show only those cases that have a date filled in the started case field. I made a button that shows the results in a report, but I would like to have it show up in a listbox so I can double click it and go straight to the case.
I have a form with various text, date and combo controls. There is a button at the button that runs a macro (Close NB) at the bottom. What I'm trying to do is bring up a msgbox if certain fields are blank and not run the macro. I only want the macro to run if all the fields specified have data in them.
The fields are : cmb_cliname cmb_disease cmb_projectType cmb_ProposalStatus
The on click code is: If (Me.cmb_cliname Is Null) Then MsgBox "Please fill in the relevant details", ElseIf (Me.cmb_Disease Is Null) Then MsgBox "Please fill in the relevant details"
I have a VBA program which is stored in an Access database. The program creates letters using Word template documents as well as new Excel sheets. When one of the users in my team undertakes this process she is unable to create the files (although she could before). The following error message occurs initially for the word documents:
"The document could not be registered word 2010. It will not be possible to create links from other documents to the document"
When I enter debug and attempt to run the code again the file opens but subroutine halts again and I get a different message:
"Could not open Macro storage"
The line of code which is identified for both errors is:
Set wdDoc = wdApp.Documents.Open(TemplateLocation)
Where wdDoc is the a Word.Document, wdApp is a Word.Application and TemplateLocation is the path for the template
I have already checked the following:
- 'Trust access to the VBA project object model' in the Trust centre is ticked and Macro Security is set to none. - DCOM Server Process Launcher is set to automatic in Services (Local)
I have a database which I've creating but now want to make others available to update - in the past this has not gone well! The database uses data from two excel sheets and the problem has been people do not always check if these have been updated today before running and therefore the database gets loaded with old data.I have found code that will check and display a message showing datelastmodified for a file but what i'm trying to find is code which will check both files' datelast modified, if they are modified today then run the update macro, if one or both are not modified today, then to display a message saying that the excel is not updated.