473,386 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Default Value from Module

106 100+
Hi I need help to clean up my module usage and to use it to bring up a deafult value for a field.

My Module that works fine when used as code in a form
Expand|Select|Wrap|Line Numbers
  1. Public Function mgmtRateCheck(StartDate, ConfirmRate)
  2.  
  3. Dim Rate1 As Double
  4. Dim DMonth As String
  5.  
  6.     DMonth = month(StartDate) & "/" & Day(StartDate) & "/" & Year(StartDate)
  7.  
  8.     Rate1 = 0
  9.  
  10.     Rate1 = DLookup("mgmtRate", "tblmgmtRate", _
  11.     "RateDateStart <= #" & DMonth & "#" & " And RateDateEnd >= #" & DMonth & "#")
  12.  
  13.     ConfirmRate = Rate1
  14.  
  15. End Function
  16.  
this is how I use it in a form and it works fine
Expand|Select|Wrap|Line Numbers
  1. Call mgmtRateCheck(Date, ConfirmmgmtRate)
  2. Me.mgmtFee = ConfirmmgmtRate
  3.  
How do I utilise it as a Default Value function for a field on a form.

Thanks
Oct 24 '09 #1
2 2778
ADezii
8,834 Expert 8TB
@tasawer
Unless I am way off base on this one, you are:
  1. Passing the Current Date to the Function.
  2. Rebuilding the Current Date within the Function.
  3. Retrieving the Return Value from the Function via one of its Arguments.
  4. If this is all correct, then the Function can be simplified to:
    Expand|Select|Wrap|Line Numbers
    1. Public Function mgmtRateCheck()
    2. Dim Rate1 As Double
    3.  
    4. Rate1 = 0
    5.  
    6. Rate1 = DLookup("mgmtRate", "tblmgmtRate", _
    7.         "RateDateStart <= #" & Date & "#" & " And RateDateEnd >= #" & Date & "#")
    8.  
    9. mgmtRateCheck = Rate1
    10. End Function
  5. To Set the Default Value of a Form Field (Text Box) equal to the return Value of this Function, set its Default Value (Properties ==> Data Tab ==> Default Value) equal to:
    Expand|Select|Wrap|Line Numbers
    1. =mgmtRateCheck()
Oct 25 '09 #2
tasawer
106 100+
Hi Adezzi, we are partly there.
This is one solves the default value for me. Thx

In the 'tblmgmgrate', I have managment rate fixed between two dates.
I need to pick the rate according the invoice date

When an invoice is created, it gets current date as invoice date and mgmtrate can default to your solution above.

However, when entering a backlog of invoices, InvoiceDate will be entered manually hence the need to re-select mgmtrate.

I hope this makes sense.

Regards
Oct 25 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

46
by: J.R. | last post by:
Hi folks, The python can only support passing value in function call (right?), I'm wondering how to effectively pass a large parameter, such as a large list or dictionary? It could achieved...
3
by: N?ant Humain | last post by:
I have just begun learning Python so that I can write a simple script to make modification of a file used by another Python script easier. This file is basically a list of regular expressions. What...
8
by: Nick Coghlan | last post by:
Time for another random syntax idea. . . So, I was tinkering in the interactive interpreter, and came up with the following one-size-fits-most default argument hack: Py> x = 1 Py> def...
3
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
44
by: gregory.petrosyan | last post by:
Hello everybody! I have little problem: class A: def __init__(self, n): self.data = n def f(self, x = ????) print x All I want is to make self.data the default argument for self.f(). (I
21
by: planetthoughtful | last post by:
Hi All, As always, my posts come with a 'Warning: Newbie lies ahead!' disclaimer... I'm wondering if it's possible, using raw_input(), to provide a 'default' value with the prompt? I would...
11
by: prefersgolfing | last post by:
I'm trying to find on MSDN, or someplace, that speaks to variables being public or private by default. Anyone know where? Thanks.
12
by: Edward Diener | last post by:
Given value class X { public: // Not allowed: X():i(100000),s(10000) { } // Allowed void InitializeDefaults() { i = 100000; s = 10000; } private: int i;
0
ADezii
by: ADezii | last post by:
The motivation for this Tip was a question asked by one of our Resident Experts, FishVal. The question was: How to Declare Default Method/Property in a Class Module? My response to the question was...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.