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 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

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

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 1 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

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

How Do I Call The User Name?

Jul 6, 2005

I am using some code found on this site to creat a log in process. It works great but I want call the UserName and insert it into my database showing
Welcome<Username> you are currently logged in..

Can someone tell me how to call this from a form?
following is the code behind the log in on the "Onload" event.
Thanks in advance.
Fen

Private Sub Form_Load()
On Error GoTo Err_Form_Load

'To ensure a user has logged on correctly we check to see if a userlevel has been set.
'I use the same Select Case below in the "Form_Load" event of each form as some forms you
'may want to set different thins for different user levels rather than setting them
'globally in a module.

With Me

Select Case User.UserLevel

Case 1 'All OK


Case 2 'All OK


Case 3 'All OK
.Command26.Enabled = False
.cmdOpenUsers.Enabled = False

Case 4 'All OK
.cmdOpenUsers.Enabled = False
.AllowAdditions = False
.AllowDeletions = False
.AllowEdits = False

Case Else 'No userlevel set, must have got here via devious means !!

' MsgBox "No User Level Set. ", vbCritical, " LOGON ERROR"
DoCmd.Close acForm, Me.Name

End Select

End With

Exit_Form_Load:
Exit Sub

Err_Form_Load:
MsgBox Err.Description
Resume Exit_Form_Load
End Sub

Private Sub Form_Unload(Cancel As Integer)
Call LogUserOff 'Called from the Unload event incase the user just clicks the main
'Access Window Close Button or exits the Db some other way.

End Sub

View 4 Replies View Related

Call Module?

Sep 8, 2005

I have a bunch of Forms set up in Access that are updating tables etc......

At present 100% of the code is sitting on the Form. I have some code that is repeated because of a string parsing issue. What I am thinking of doing is writing this code as a couple modules and then call them when needed.

Does that make sense to write them as modules and call them?

How do you call a module???

Thanks

View 4 Replies View Related

Forms :: SUM Function Produces Error From Calculated Function

Jan 30, 2014

I have a project at hand and it's been a predecessor of mine and client has asked me to do some work on it and extend functionality - but I have not really delved into Access before and I have had to worked my way through to this final snag :/

The Main Form has one sub form. This sub form allows the user to add multiple order items i.e. qty, stock, description from records within the system - fairly straight forward.At the last column of each row is the sub total of those particular items i.e.

Qty Unit | Item ID | Total
-----------------------
2 | 1234 | 80.00
------------------------
1 | 43526 | 20.00
------------------------
> | |

So the total is a function of =[Qty Unit] * [Unit Price].Then in the Footer of this SubForm is the Sub Total

=SUM([Qty Unit] * [Unit Price])

All fine and well..... However, the additional functionality kicks in.

Lets add the additional customer_id from the Main Form. Each Item bought is dependent on the customer_id i.e. they get special prices depending on who they are.So a New table is made which has the Item ID and SpecialPriceID (of a table to define as a specialPrice) and the Price linked to this Item and Special Price category. So say that there are two groups of users "wholesale" and "nonwholesale" these would be SP_1 and SP_2 and each client is defined either one of these, and each stock item has a Price for each SP_1 and SP_2. Hopefully I've explained myself there.

Back to the SubForm. So now the Total needs to calculated differently with needed the external customer_id from the Main Form.

Code:

Function CalculateSpecialPrice(ItemID As String, CustomerID As String, Unit As Integer)
Dim SPSelect As String
SPSelect = "SELECT Price FROM [Items_SpecialPrices] WHERE"
SPSelect = SPSelect & " ItemID = '" & ItemID
SPSelect = SPSelect & "' AND SpecialPriceID = (SELECT SpecialPriceID FROM Customers WHERE customer_id = " & CustomerID & ") "

[code]....

its the sub total I just keep on getting #Error on. I have even watched (using alerts) that the correct return variable is the same as the individual rows. This is the equation I used for the SubTotal within the footer.

=SUM(CalculateSpecialPrice([Item ID], [Form]![FormName]![CustomerID], [Qty Unit]))
#Error

View 2 Replies View Related

Call Centre Database

Apr 6, 2006

Hello all,

Im really hoping someone can take a look at my database and help me!!

I have a query within my database that hold five different Departments, and each department has two difference phone numbers.

What im trying too do is add together the statistics of the two phone numbers that relate to the department!

And also be able too do a search by a cumulated date range, and by multiple departments!

Please, please, please, could someone look at my database and advice me

Many Thanks

Mark

View 1 Replies View Related

Call Procedure On A Different Form

Aug 30, 2006

Hi,

Is it possible to call a procedure that exists in one form on another form please?

Regards,
B

View 13 Replies View Related

Creating Call Lists

Nov 15, 2006

I am trying to create call lists which will compile one-to-many relationships.

For example, suppose I have 1000 employee records with the following fields:

Manager's Name
Manager's Phone Number
Direct Report's Name
Direct Report's Phone Number

Each Direct Report has only one designated manager, but managers may have more than one direct report. Further, for roughly half of the records, the manager and the direct report are the same person (independent workers).

When I run the report, I want it to print the Managers' information, and have the Direct Report information below. I have added an IIf query stating that if the Manager's Name is the Same as the Direct Report's name, leave all of those cells blank. When I create a report, however, the labels for Direct Report will still show but the data does not. It looks somewhat shoddy.

View 2 Replies View Related

Call Out Data Base

May 21, 2007

hi i want a call out database with a calender with blocks in to represent slots booked and free, with a form with time start, duration (default 60mins) address, work to do, and milage. and the a report for the customer to sign. i have tried for about 6 months with different ways and means, to no aval, it would help if i had som knowledge of vb programing, ect, i have basic knowledge of access, eg add data, search data, and reports. please can someone helpme design one, as i would be very greatful, thanks in advance

View 2 Replies View Related

ODBC Call Failed

Jul 16, 2007

I have a new user who is trying to connect wirelessly. I set up the ODBC connection on his laptop but when he tries to run a report that uses queries looking at linked tables he gets ODBC call failed. Is it because he is trying it wirelessly. I'm just the data guy so I don't know too much about networking.

View 2 Replies View Related

Difference Between 'Call' And 'DoCmd'

Apr 8, 2008

Can someone tell me the difference between 'Call' and 'DoCmd' and how each are executed. For my level of programming, an newbie at that, I've used it interchangably so far without a problem. But I'm beginning to think that there is a difference. I don't want to later have to go back to redo my code down the line. I'm beginning to think that I've been very lucky so far in being able to use it interchangebly and my luck will run out soon.:eek:

View 7 Replies View Related

ODBC Call Failed

Mar 7, 2007

Hi,

I have a standalone Access DB with 4 linking tables therein. They all point to tables that are stored in a server Access DB. I can open 3 of these tables in datasheet view without any problem, except one.
Whenever I try to open it, I am prompted following msg "ODBC call failed etc... server API error (#669) etc..."
And when I click OK to close the Error msg box, then another msg box appears with the msg: "Microsoft Access can't open the table in Datasheet view"

I've deleted the link table and recreated it. But I still can't open the table in datasheet view.
Does anyone knows what's to do? :confused:

View 3 Replies View Related

Invalid Procedure Call

Oct 14, 2005

why aint this working ?

Expr1: Mid([MinuteCode];1;InStr(1;[MinuteCode];".")-1)

View 14 Replies View Related







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