access-vba

ms access if in sql

I am trying to update the column called NewNumber. What I want to do is if the column phone_code has 1 in it, I want to update the column NewNumber with the value of the phone_number column. But if it is anything else than 1 then I want to concatenate the phone_code and phone_number columns and update NewNumber column. Below is the code ...

Use Value in Word calculated with VBA in Access

I've to use a Microsoft Access Database to create different bulk letters in Microsoft Office Word. This works just fine in most cases but it is somehow not possible to use a View (which is defined in Access) in Word as long as the source for data contains a column that is calculated by VBA code in the Access Database. Ah, and I need exac...

Using antlr to remove dead code

Hi! I am currently servicing an old VBA (visual basic for applications) application. I've got a legacy tool which analyzes that application and prints out dead variables. As there are more than 2000 of them I do not want to do this by hand. Therefore I had the idea to transform the separate codefiles which contain the dead variable acc...

vba format function throws type mismatch error

I am trying to format a number as currency in Access VBA. In the immediate window, when I enter: ? Format(123, "Currency") I get the expected response: "$123.00" However, in the code window, when I enter: Debug.Print Format(123, "Currency") I get an error pointing to that line: "Run-time error '13': Type mismatch" Why does the s...

Compile Error in VBA code in MS Access

I have the following function in access, which was working fairly well. But now suddenly i am starting to get a compile error : Method or data member not found Function Serialize(qryname As String, keyname As String, keyvalue) As Long Dim dbs As Database Dim rs As Recordset Set dbs = CurrentDb On Error GoTo Err_Serialize Set rs = dbs.O...

A little buggy: Code to create, save,& open a Lotus Draft Email thru VBA

This function was written to create a Lotus email, populate it, save it to the Drafts section, and then open it for the user to edit. However, it has 2 problems: It doesn't always open the right draft email for editing. It sometimes produces a "Notes Error - Specified command is not available from the workspace." error message. (The e...

What is &H20 and &HDF in VBA?

I am trying to grok the following piece of code: Mid$(strV, i, 1) = Chr$(intChar And &HDF) What does &HDF mean? I also have a similar section that uses @H20. I have Googled high and low and the most I found was nothing that I didn't already know about them...that they are constants. ...

Event not Firing in MS Access VBA

I have a form in MS Access which has an image. The image has an Click event which opens a modal form. The modal form has an OK and Cancel button. When you click the OK button, an event is supposed to fire which tells the main form which button was clicked. (This is to simulate the DialogResult functionality in C#). However, the code...

How do i pass a full directory of XML files into XSLT

The following XSLT is transforming file1.xml and file2.xml. How do i replace those 2 files with a full folder listing of all the XML files? I am using VBA in Microsoft Access, and this stylesheet solves the problem of merging multiple files (credit to Alejandro) without dropping any newer fields as was the case during XML import. It ...

Check Microsoft Access Form Values before Save

I have an Access Form - lets call it "Add Labor" (Access 2007) that saves data into a table. The table has two columns in particular called "Start Date" and "End Date" (This table stores tasks) There is also another table called FiscalYears which includes Start and End Dates for Fiscal Years, which is structured as follows FyID FYear...

Updating a table Access and Excel VBA

Hi, I have one table called: Transaction. This table has the following fields: (ID,ProductName,Amount,Date) placed in an excel sheet that is connected with MS Access database. ID is the only unique field. Sometimes, my user submits a transaction that has let's say 5 records. Then, they want to modify the submitted data in case if they en...

MS Access Auto Link Excel Spreadsheets

I have a directory structure where I am managing the requirements of a system with each component of that system having its own directory. the requirements of each component are stored in a excel workbook that has multiple worksheets(# of worksheets are static). I am currently using access as a central location to view the information ...

Is there a NotIn("A","B") function in VBA?

I'm writing a function that requires input and my data validation looks very awkward. If InputFld isn't "A","B", or "C", then it's an error: If InputFld <>"A" and InputFld<>"B" and InputFld<>"C" then goto ErrorHandler This just looks ugly to me. Is there a more elegant solution? I'd like to just write something like: If InputFld not...

Using linebreak to break IF statement in Access VBA

I have a VBA conditional script as below: If COMORBIDITY_CANCER = -1 Or COMORBIDITY_CHRONIC_SKIN_LESIONS = -1 Or COMORBIDITY_CHRONIC_LUNG_DISEASE = -1 Or COMORBIDITY_CARDIOVASCULAR_DISEASE = -1 Or COMORBIDITY_DM = -1 Or COMORBIDITY_IMMUNODEFICIENCY_OR_CHEMOTHERAPY = -1 Or COMORBIDITY_ADL = -1 Or COMORBIDITY_HEPATIC_DISEASE = -1 Or COMOR...

How to simulate an ODBC time-out error?

I am testing the error-handling of an Access-VBA controlled process: A script in an Access 'controller' DB starts. The script starts a macro in a 2nd Access file (the 'database'). The macro in the 'database' file runs a bunch of maketable queries. These queries pull from tables linked to an ODBC source (SQL-Server actually). When thi...

If [ComboBox] Is Null Statement in VBA/Access 2007

Hi all, I have a form with 1 combo box (YearToBeBuilt) and 2 text box fields (Cost and YearofExpenditureCost). All controls are linked to a main table and the table is updated once the selections/entries have been made on the form. I have written a procedure in VB called ReCalcIt()which performs the following procedure when called: ...

MSAccess - populate text box with value from query

I have a combo box and several text boxes on a form. When I select a value from the combo box I want it to run a query based on that value and populate the text boxes with the data returned by the query. The query should only return one record and the textboxes correnspond to different columns in that record. I have this code: Private ...

oAuth client in Office VBA what is difficult ?

I cannot find any oAuth sample code and saw others were desperately searching for it, what's the difficult part to implement an oAuth client in VBA ? ...

In access-vba, what triggers run-time error 2046 (The command or action 'RunSQL' isn't available now)

There is an oddity in my VBA module. Sometimes I get a run-time error 2046: The command or action 'RunSQL' isn't available now. When I try it again later, without changing any code, it no longer gives the error, some time later, it does again. Does anyone know what triggers this run-time error? And how can I avoid it? I think the prob...

DoCmd.OutputTo On Report Doesn't Unload

In Access 2007, I have a form set up to allow previewing and exporting options for the project's reports. DoCmd.OutputTo seems to behave strangely when dealing with reports that have the Modal property set to true. Modal is currently set to True in the Open event for all of the reports that I'm working with. If I do DoCmd.OpenReport s...