Call A Function In Excel

Oct 29, 2004

I have linked an excel workbook as different tables in Access.
The workbook contains a Microsoft Query. I have now found out how I can open and edit the workbook from access, how can I Update/refresh the MSQuery before I close it?

Here is what I have:
Private Sub cmdTest1_Click()
Dim MyXL As Object
Set MyXL = CreateObject("Excel.Application")
Set MyXLSheet = GetObject("c: est.xls")
MyXL.Application.Visible = True
MyXLSheet.Parent.Windows(1).Visible = True
MyXL.Application.Cells(1, 1).Value = Now()
MyXLSheet.Close SaveChanges:=True
MyXL.Application.Quit
Set MyXL = Nothing

End Sub

eroness

View Replies


ADVERTISEMENT

Modules & VBA :: Static Shell Function Call Works But Dynamic Call Fails

Sep 4, 2013

I'm having to recode some old MS Access DBs so they will run in the following environments:

Office 2000 on WinXP
Office 2003 on WinXP
Office 2010 on WinXP
Office 2000 on Win7
Office 2003 on Win7
Office 2010 on Win7

When I wrote my code for Office 2000 on WinXP things were simple because directory paths were the same across all computers and I could hard code pathing when using a shell command to launch other files.

My new approach is to make a function call to the Windows registry to determine the default executable and path for opening a file based upon its extension (see apicFindExecutable in basWindows API module).

I'm able to use code to create a shell call and debug print it to the immediate window. If I put my cursor in the immediate window at the end of the shell call and hit [enter] the external file will open as desired. If I try to open the external file directly through code, I get a file not found error.

To recreate the error take the following steps:

(1) browse to files that are accessible from your computer
(2) click the PREPARE DATA AND OPEN MAIL MERGE DOCUMENTS command button

Shell function call is made by the fnOpenFile function located in the basOpenFile module. There has to be a trick here that I'm missing.

View 5 Replies View Related

Modules & VBA :: Export To Excel And Call Macro From Other Excel?

Aug 25, 2013

i want to export a table to excel , open this file and execute a macro from another file.

the code i have now is :

Code:
DoCmd.OpenTable "Overzichtaanwezigheid", acViewNormal
DoCmd.RunCommand acCmdExportExcel
DoCmd.Close acTable, "Overzichtaanwezigheid"
Dim XL As Object
Set XL = CreateObject("Excel.Application")
XL.Workbooks.Open ("C:UsersErwinDocumentsOverzichtaanwezigheid.xlsx")
XL.Visible = True
XL.Run "d: est.xlsm!Macro3"

Opening the excel file goes ok, running the macro however not.

View 1 Replies View Related

How Do I Call This Function?

May 3, 2007

I did some searching and found this function posted by someone in response to the exact same problem I'm now encountering.

But how do I call this in my query?

Function StripZeros(pstr As String) As String
Dim n As Integer

n = 1
Do While Mid(pstr, n, 1) = "0"
n = n + 1
Loop
n = IIf(n > 1, n, 1)
StripZeros = Mid(pstr, n)

End Function

View 2 Replies View Related

Function Call From Qry - What If Null???

Dec 1, 2005

Hi all!

I have a query that returns some fields with "#Error" ...

The reason is that I call a function in the query, and the function chokes if there are no matches in my query criteria and therefore no argument is sent to the function.

I tried putting this in the function:
var = Iif(IsNull(var) = True, 0, var)
-but I still get "#Error" when there are no matching records.

I presume this is because not even Null is given to the function as an arg.
Should I make the arg optional or how can I solve this??

Thanks :)

View 6 Replies View Related

Using A List Box To Call VBA Function Or Macro

Feb 23, 2007

http://www.access-programmers.co.uk/forums/showthread.php?t=123538

Following on from that thread, I would really like to tidy up other areas of my front end. I am using the idea that Roy suggested and it works very well.

At the moment, I have a form, that has buttons on it that people click when they want to generate specific sheets from excel using data from access using VBA on the form. These work fine, however, now that the database is going live and all features need to be added, I think it would be nice to have one small form, with a list box.

I have converted a copy of the code on the form and placed in a module by declaring then functions instead of private subs.

At this stage, I tried doing it with macros running the code by using a series of runcode. I then created a table that has the macro name stored in it along with a decriptive bit of text detailing the excel chart that gets produced to make it easy for the user.

The list box populates itself correctly, but the problem I am having is I do not know how to make the 'go' button look at the list box, pull the hidden macro/function name from the list, then go and run the macro/function.

I have tried looking about, but have not found anyhthing.

View 4 Replies View Related

Criteria Is Passed By Function Call

Aug 10, 2007

Dear Access Query Expert

I have created a query which has a function call as the criteria for one of the numerical fields. The function returns a string expression such as .....

1) 132 OR 142 OR 156
2) 132 OR 142
3) 132

..... into the criteria section of the numerical field.

Unfortunately, the query doesn't work if the criteria is generated by the function call. However, if I hardcode the criteria (don't send a function call but directly write 132 OR 142 OR 156) the query works.

I am puzzled and I am not sure how to solve this problem.

Thank you so much.

View 1 Replies View Related

Call A Function From A Field On A Form

Aug 8, 2006

Is it possible to call a function from a field on a form, ie, in the
control source put = FunctionName(abc)? Then I want to concantenate
it to another variable so it would look like:

=FunctionName(abc) & TextVariable

I tried this and got the ?Name on the form, like it couldn't find the field
name, which is really a function I'm calling.

Is this possible and if so, what am I doing wrong?

Thanks in advance for any help.

View 1 Replies View Related

Forms :: How To Call A Function From A Variable

Apr 5, 2014

I have the following in Form and it works OK

Call RunForm("frmProviderLookup", "", "Edit", "", "", "Normal", "Normal")

I want to build a combo box with several different RunForm variations as follows:

RunForm("frmProviderLookup", "", "Edit", "", "", "Normal", "Normal")
RunForm("frmCustomerLookup", "", "Edit", "", "", "Normal", "Normal")
RunForm("frmVendorLookup", "", "Edit", "", "", "Normal", "Normal")
etc, there are many of these

When I select one the variations from the combo box the RunForm statement is stored in strAction varaible..How do I code the Call strAction line? (I want only one call statement).In other words how to call a Function from a variable...The start of my module Function works OK and looks like this:

Public Function RunForm(FormName As String, _
Optional WhereCondition As String = "", _
Optional xMode As String = "", _
Optional filterName As String = "", _
Optional Args As String = "", _
Optional WindowMode As String = "", _
Optional View As String = "")

' Parameters (all optional except parameter 1)
' 1 - Form Name
' 2 - Where condition
' 3 - Mode [Add, Edit, View(Read Only), ""(PropertySettings), DS(Datasheet Edit)]
' 4 - Filter Name
' 5 - Opening Arguments
' 6 - Window Mode
' 7 - Form View

View 1 Replies View Related

How To Call A Written Function That Are In DLL File In A Form?

Jan 16, 2007

With the script in the form that is part of MS-Access. I wonder how do I access/call the written function that are in the DLL file I made. I appreciate your help on this one...

View 2 Replies View Related

Queries :: Call A Function Via Control Element In SQL

Jul 18, 2014

is it possible to call a function in a query with the input of a control element?

I have a form, and there is a list box in which I can choose the calculate method. In the query, a field should calculated with the choosen function.

Example:

Code : SELECT tblTest.price, tblTest.Date, forms![formtest]![lstChosenFunction](tblTest.price, 5) As Calc
...

The function has the same name as I can choose in the listbox. But, if I run the query a error appears.

Code : "Function forms![formtest]![lstChosenFunction] could not be found"

how I can call a function in SQL with the input of an listbox.

View 4 Replies View Related

Modules & VBA :: Possible To Call Windows Search Function Into Access?

Nov 3, 2014

I need a search function that will not just open files based on their names but also drill into the documents and search based on what's in it. The only way I can see now is to use the Window's search function (the one at the start button). Is it possible to call that function into access?how do I re-create the search style of the windows search bar for a specific folder? Something like streamreader

View 1 Replies View Related

Modules & VBA :: Call A Preimport Function Whenever Transfer-spreadsheet Is Called?

Oct 16, 2014

I know its not possible. But Just wanted to confirm. Not at all possible?

Code:

Function PreImport(BookToImport As Workbook)
For Each cell In BookToImport.Sheets(1).Rows(1).Cells
cell.Value = Trim(cell.Value)
Next cell
BookToImport.Sheets(1).UsedRange.Rows(1).Replace ".", "_"
End Function

View 1 Replies View Related

Modules & VBA :: Using Shell Function To Dynamically Call Different Pdfs That Are In A Directory?

Aug 13, 2013

I'm looking to use the shell function to dynamically call different pdfs that are in a directory. However I'm getting run time error 5 "Invalid procedure or call argument".

Here is the code (very basic I know)..

Private Sub Liste_Documentation_DblClick(Cancel As Integer)
Dim PathName As String
PathName = Me.Liste_Documentation.Column(2)
' Debug.Print PathName
Shell PathName
End Sub

A typical filepath name is as follows..

S:VenteVendeursMarcCRMDOCSDiligences KYC - LABFT - V 2013 04 23.pdf

View 8 Replies View Related

Call An Excel Macro From Access Module

Dec 7, 2004

I am trying to populate an Excel Shreadsheet (Template in Effect) with Data from Access. This is going ok no problem. Although I need to run an excel macro, which does some formatting to the WorkSheet after each entry in the Access Recordset. I've tried copying the VB over, but getting some errors, and frankly, I think it's easier if I just call the macro itself, rather than try to adapt it for the Access context. Though, I accept it would be a cleaner approach. Can I do this?

View 1 Replies View Related

Modules & VBA :: Unable To Call Excel Functions

Jul 15, 2013

I spent all day trying to figure out why sometimes I can call an excel function from access and the value will appear on my form, but for some functions (F.inv, binom.inv), it errors out as "object not supported". I browsed all the available libraries in tools/reference but found nothing that seemed to solve this issue.

View 7 Replies View Related

Reports :: Export To Excel - Invalid Procedure Call

Mar 25, 2013

When I try to do an export to excel for a report - it comes back with a message saying Invalid procedure call or argument .

View 3 Replies View Related

Need To Use Excel Function In Access

Jan 15, 2007

Hi,

I am trying to use the YIELD worksheet function in Access but can't get it to work. It comes with Error Sub or function not defined.

As per help file I have installed msowcf.dll but it still doesn't work.

Any ideas?

Thanks

View 12 Replies View Related

Nz() Function Does Not Work With Excel

Nov 26, 2007

Hallo guys,

I am stuck with a simple fact. Nz() function works in Access queries. When I try to import data via these queries into Excel, it says : Nz is not recognized. So anyone knows a good replacement for Nz() that works in Excel as well?

With kind regards
Maxim

P.S. I use office 2003.

View 2 Replies View Related

General :: Replicating Excel Function

Oct 10, 2014

Is it possible to compare rows, ie in excel I could do =A1=A2 to compare certain fields then if they are different/the same highlight.Is there a way of doing this in access?

View 1 Replies View Related

Using Excel Function Forecast In Access?

Jul 12, 2013

I am trying to use the Excel worksheet function "Forecast" to calculate from existing data in my database. I have successfully gotten the data points into arrays, but when I try to call the forecast function I keep getting the following error: "Unable to get the Forecast property of the WorksheetFunction class". I have imported the object library. This is on a company computer and I do not have write privileges to the C: drive. The database resides on a network drive.

Am I facing some sort of security issue?

Public Function xlForeCast() As Double
Dim MyHeight As Variant 'Will be the point for which you are forecasting, in this case height
Dim MyRange() As Variant 'Will be the independent element of the forecast function
Dim MyRange1() As Variant 'Will be the dependent element of the forecast function
Dim MyArray() As Variant 'Temp array to hold the query result set values before being split into the two preceding arrays
Dim db As DAO.Database

[code]....

View 1 Replies View Related

Queries :: Can Access Expression Builder Mirroring (IF Function) From Excel

Dec 12, 2013

I need to clean up data from text file which is huge.

I wonder if Access Expression Builder can mirroring "IF function" from Excel Here is what i am trying to do The data consist of multiple customer and multiple date. But the layout only specified customer ID once eg.

CustID: aaaa
Date
01012013
02012013
03012013
CustID: bbbb
01012013
02012013

When exported the file I used Fixed Width command to separate Date Column and Cust ID column.

Below is the result that I am looking for
CustID: aaaa : aaaa
Date : aaaa
01012013 : aaaa
02012013 : aaaa
03012013 : aaaa
CustID: bbbb : bbbb
01012013 : bbbb
02012013 : bbbb

1. Column A is Date

2. Column B is Customer ID

because Customer ID in column B only appear once, I need to create another column to populate that Customer ID whenever the transaction related with that Customer

3. Column C is the column where i tried to populate Customer ID to each date related to that Customer.

If I worked in excel the formula will be --> IF(AND(C5="",B6=""),"",IF(AND(C5="",B6<>""),B6,IF( B6<>"",B6,C5)))but in access i am stucked.

View 14 Replies View Related

Queries :: Importing Excel Text Field Into A Table - CDate Function?

Apr 28, 2014

I am importing an excel text field into a table. I am then appending the data to another table. I am having a hard time with the Cdate function

Excel Date Field:
YYYY.MM.DD HH:MM:SS

Example Value:
2014.04.21 18:24:30

My Query Code:

NewDate: CDate(Left([DateQ],4)+"/"+Mid([DateQ],6,2)+"/"+Right([DateQ],2))

My Query Result:
4/30/2014

What it should be:
04/21/2014

View 12 Replies View Related

Automate The "Export To Excel" Function?

May 10, 2007

Hi guys,

I regularly export the main table in our database to an excel spreadsheet, to provide an additional level of data back-up. (Using File/Export)

I was wondering if there is a way of automating this process, either through a command button on a form, or by linking it with shutting the database down.

Any ideas?

View 1 Replies View Related

Modules & VBA :: Creating A Function That Counts Records And Use That Function In A Query

Dec 11, 2013

So basically I need making a function that will count the number of records from another table/query based on a field from the current query.

View 2 Replies View Related

Do Not Call Database

Jul 6, 2006

Hi,


1. We have one master table with many records.
2. We'd like to filter out records from the "master" table that match the records on other "exception" tables.
3. As I add records to the "exception" table, I'd like to generate a new table with the records from the master minus the exception table.

I've been reading up and I think that this could be done with queries.
Any suggestions?

Thanks,

Adrian

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved