vba

Building SQL strings in Access/VBA

Occasionally, I have had to build a SQL string in VBA and execute it with Docmd.RunSql(). I have always built these strings by concatenating variables into the string, e.g: Dim mysqlstring as String mysqlstring = "INSERT INTO MyTable (Field1, Field2, Field3 ...) VALUES (" mysqlstring = mysqlstring + Me.TextMyField1 + ", " 'parameter com...

Graph on an access form

Hi, I have some code at the moment to draw a graph based on the values of a series of text boxes on an access form. I’m happy with the code and how it works but I’m not convinced that it is the most efficient way of doing this. The graph takes about 1.2 seconds to redraw each time. The form is unbound so it is just getting the values f...

Assign rights to folder VBA

Hi , I use the below code to assign rights to the folder this works fine when i create a folder on say "C:/Test" and run the code it works fine without any issues but once i try the same with the folder "C:/Documents and Settings" i get an error . Here is the code its a VBA code done on a word document. Dim intRunError, objShell, o...

Does anyone know what the code looks like for a VBA OLE Attack (to discover VBA level passwords in Office documents)

This is not a hacking question (as such) I am writing an in house tool for our Service Management Team to reset/remove lost passwords from Office Documents. I have the PassWare Program that does this already but want to incorporate the function into a VBA script. ...

Moving values from one sheet to another

I'm looking for an Excel 2003 macro to solve this problem. I have a sheet that holds financial information: A1 holds client names and AI1,AK1,AM1 etc, hold months April, May, June (all string values) etc; with the rows below that holding the amount due for the corresponding month. The last row is the total. What I need is to cre...

FTP connection and upload under proxy using command prompt and Putty

Dear all, I have a small access database which makes CSV file that should be uploaded on a remote FTP server. I need to make automated process to upload a file using command prompt (which I access through VBA shell). Issue is that I can access internet only via proxy, and can't seem to find any resource online on how to set up putty (...

Organizing VBA Project

Hello people, I am maintaining a large MS Access Project. Over time the number of modules and classes has grown, at this moment it contains 90 modules. More and more time do I spend searching for a specific class in the list. (I know about Shift+F2 :)) Is there any way to organize the list of modules in the VBA editor, i.e. some kind o...

Macro too big to run, keeps 'not responding'.

Hi I have now managed to write my macro but the whole thing stops responding, just a guess but i presume it is because it is asking to check too much data? I have about 3000 rows (but have even tried it on 10). Does anyone know how I can cut this down or mend it to work? Another query on it I have gone to the heading 'sample187' but idea...

ADO Connection to Access leaves .ldb file behind

I'm writing an MS Outlook (2003) macro which uses an ADO Connection to an Access DB (2003). I am simply opening a connection, getting some records into a Recordset, which I use to populate a grid (but not bind to). I then close the Recordset and Connection and set both to Nothing. Not rocket science is it? But I am getting an infuriatin...

How to do Distributed Calculations in Excel

A number of years ago I implemented an asynchronous peer-to-peer Message-Oriented-Middle-ware that was very friendly to use in Excel VBA, and I find myself again needing to do lots of calculations which could be trivially distributed, if I had the mechanism. I could re-implement the MOM layer, but I'd prefer to use a third party product...

Does anyone know of a VB(A/6) example using GetLocaleInfoEx?

I thought I dug most of what I need out of the header files, but I keep crashing out. Here is the declare I tried using, but I don't think it's just an issue of the declare. I think I'm actually using it wrong. Private Declare Function GetLocaleInfoEx Lib "kernel32" ( _ ByVal lpLocaleName As Long, _ ByVal LCType As Long, _ ByRef lpLCDat...

Determining size of printed page in Excel VBA

In Excel VBA is there a way to determine the width in units of a printed page? Dim remainingWidth as Double remaningWidth = <property that gives printed page width> - _ ActiveSheet.PageSetup.LeftMargin - _ ActiveSheet.PageSetup.RightMargin - _ Range("A:H").Width ...

How to refresh listbox

What's the best way to refresh a list box in MS Access? The way I have tried it doesn't seem to work :-/ This is my current method (onClick event of a button on the same form): Me.orders.Requery I have also tried orders.Requery and Forms!currentOrders.orders.Requery but none of them seem to refresh the list box's contents - I ...

Convert a file into PDF with a Visual Basic script

Hi, I'd like to know how to convert a file into PDF when I'm programming in VB. Do you have the script or if there is a pre-defined function, what is it's name? Thanks ...

VBA Code Stops Working

The following code is called everytime the form is opened. It works great until the 5th opening and then misses deleting one of the controls. Anyone know why this is? For Each cb In Forms(frmName).Controls If cb.ControlType = acCheckBox Then If Left(cb.Name, 3) = "clr" Then DeleteControl frmName, cb.Name ...

Write to two cells at same time excel vba

I need to write the same data into two different range of cells for a VBA application that I am writing. I could of course just loop through twice and write the data, but I was hoping to do it in one pass. This is an example of what I am doing (lot of complexity removed). Sub WriteData() WriteOutDivision "Division1",10 Writ...

Prevent Access from Changing Queries

Hello, Microsoft Access wants to be helpful and change my queries when underlying object (either form or query) does not exist. For example, if I had a query that did the following... SELECT FirstName FROM persons If the persons table does not exist yet, and I import the query, Access will place an "expr: " in front of FirstName si...

excel macro to save as filename excel file and close open excel file

how to add a step at the end of an excel macro to save the processed excel file with name finaloutput.xls in given path on computer and then automatically close the active excel file without saving changes. ...

MS Access 2003 - Linking one form to multiple tables, and saving data on click

So I have a form that I want the user to use to update multiple tables with. I do not want the form to be bound to the tables, as I would rather do this with VBA (I think, I don't know). So here is a little table example UserTable UserID First Middle Last Division Title EquipTable EquipID AssignedLaptop Model Barcode SoftTable S...

Late binding an Object in VBA

I am getting the "run-time error 429" in my attempt at late binding to the VBProject object: Dim vbProj As Object Set vbProj = CreateObject("ActiveDocument.VBProject") Is there something fundamental I am failing to understand? For example, how would you write the code in article 308340 to use late binding?: Sub CheckReference() ...