Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying public constant in textbox 2

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
579
0
16
GB
Hello I have a module called Settings, in which I have a public constant called Interval (which = 12)

I would like to display this value in a text box on a form, but cant seem to do it.

How can this be done?

Thank you Mark
 
Thank you for your help thus far.

I have never written a function before -

So I have the following:

A module called Application_Settings
A table called PROPERTY
A field in that table called STARTDATE

I would like an unbound textbox on a form to show the start date + 10 days

I have created the following function in the module but it doesn't seem to work:

Code:
Public Function AfterStart()

AfterStart = [property].[startdate] + 10

End function

In the unbound textbox control source I have : = Afterstart()

This just shows as error.

The form is bound to the Property table.

Sorry that this is such a basic question.


In addition I have created a Settings table in my database to store commonly used values. I refer to these by a Dlookup. Am I better to use Public Constants in a module rather than a Settings table? Thank you.








 
As the form is bound to the property table you may use this control source for your textbox:
=[stardate]+10

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yes I understand I can use =[startdate]+10, but I want to refer to the Public Function if possible (I want to do this so I can just change the public function and it would then update the textboxes which refer to this throughtout the database.

Can this be done? Thanks Mark

 
Code:
Public Function AfterStart()
AfterStart = DLookUp("startdate", "property") + 10
End Function

And the controlsource:
=AfterStart()

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry to be back again...

I thought all was working but I now see that the date being picked up is not the current record.

I have tried...

Code:
Public Function AfterStart()
AfterStart = DLookUp("startdate", "property","prop_id = me.prop_id") + 10
End Function

(prop_id - being the primary key)

Help appreciated - Thanks
 
Code:
Public Function AfterStart() as date
  dim strWhere as string
  strWhere = "prop_id = " & me.prop_id
  debug.print strWhere
  AfterStart = DLookUp("startdate", "property",strWhere) + 10
  debug.print afterStart
End Function

run the above version, and reply with the debug.
 
Thanks, but this gives me the error of

Invalid use of Me keyword

Any ideas? thanks
 
Which sounds like you are running the function from a standard module and not the forms class module. If that is the case try
strWhere = "prop_id = " & forms("yourFormName").prop_id
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top