Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 24th, 2006, 03:33 PM
Authorized User
 
Join Date: Apr 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Are Optional Parameters supported in Access 2000?

I wrote a vba function to check the fields on my form against a table to determine the validity of the combination of field values. The function is called from each of the field controls and passes its text value and field name. In the function the either text value or the control's value is assigned to a local variable for each control on the form being validated. This function is also called from the form's current record event, but only empty strings are passed to the function. What I'd like to do is make both parameters optional, but the syntax checker won't let me. This seems strange because Excel 2000's vba will let me use optional at the beginning of a function's parameter list. Aren't the two applications using the same core vba engine?
 
Old April 25th, 2006, 06:42 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

The two applications are both using VBA, but they both have different application models.

What are you trying to do with the optional syntax? What conditions determine whether to run the function or not? I am sure there is a way to do this, but I am not sure what you are trying to do optionally.



mmcdonal
 
Old April 26th, 2006, 10:01 AM
Authorized User
 
Join Date: Apr 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I recently was writing vba code for Excel 2000 and used the optional parameter convention in one of my parameter lists. However, when I tried this in Access 2000, when I added Optional to the beginning of one of my function's parameter list, the editor would highlight the Optional word as an error.

I've written a function to look at the content of the user modifiable fields on my form and determine if they contain valid data in relation to each other. I call this function from each of the exit events of these fields and pass the field's name and its text value. I also call this function from the forms current event and pass in two empty strings.

The function looks at these input parameters and if a field name and text value is passed in then it uses the text value instead of the fields value. When empty strings are passed in then only the field values are used. What I'd like to do is make the field name and text parameters optional, then I wouldn't have to pass in two empty strings. Not a big deal, but I found it strange that the optional parameter didn't work.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Alternative to optional parameters in C# asptwodev BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 November 12th, 2007 03:47 AM
Disabling/Hiding Parameters MRS 2000 arul1984 Reporting Services 0 July 10th, 2007 04:48 AM
2000 Multiple Parameters jpenn Reporting Services 1 July 19th, 2006 01:39 PM
optional parameters in SP yuqlin BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 7 July 13th, 2004 03:28 PM
Optional Stored Proc Parameters? VBAHole22 SQL Server 2000 3 August 13th, 2003 11:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.