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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

End-user to change default value?

Status
Not open for further replies.

valkyry

Technical User
Jan 14, 2002
165
0
0
US
I have a form with certain fields defaulting to certain values.

The end-user would like to change the default value.

Meaning, LaborRate field is defaulted to $12 so for every quote entered the LaborRate automatically has teh $12 value.

The end-user would like the ability to change it, let's say starting next week the LaborRate will change to $15. For every quote entered from then it'll default to $15.

How can I create something to allow the user to change the defaulting values?

Hope I made sense :)
 

I have an app that needs to do printouts with the end user's address, phone numbers etc on them. So that they can change these if any of the contact info changes, I simply have a small utility table for this purpose, with a simple form for inputting the data. The form's roperties are:

Edit Allowed = Yes
Additions Allowed = No
Deletions Allowed = No

Then I simply reference the table when a "letterhead" is needed for a printout. I don't see why you couldn't do the same. Maybe someone else has a slicker way to do this! As my signature says, "There's always more than one way to skin a cat!"

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
valkyry . . .

Is this on a network?

Calvin.gif
See Ya! . . . . . .
 
Hi TheAceMan1,
any ideas?

NOTE: the option to create master tables and using the current info for the default is an option.

example:
tblLaborRate will have two fields:
LaboRate
RateAffectiveDate

And something like a DMax to get the most current date to pull the current LaborRate is an option BUT, if this is the only option, I'm not sure how to have the form control pull the DMax value as the DeFAULT value??
 
valkyry . . .

To my knowledge you can't change properties of a table field on a backend from the frontend. Even if you did it manually from the backend the big problem is [blue]you have to have exclusive use of the table![/blue]

In the meantime I'm checking my resources and a few brainstorms.

[blue]Yout Thoughts! . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Anyway of having the field on the form (the control) have the DMax in the Default field?

So, how would I write:
=DMax("LaborRate","tblLaborRate") - this returns the highest laborrate regardless of date. need the return the laborrate of the most recent date (max date).

but not the max on the LaborRate but the max on the date then return the LaborRate??

Did that make sense?
 
valkyry . . .

Sorry to get back so late . . . didn't forget you.
[blue]NOTE: the option to create master tables and using the current info for the default is an option.[/blue]
This appears to be the best way to go as far as a central point global to the network is concerned. [blue]This would be a one record table with fields containing current default values.[/blue] You also have the advantage (thru access security) of restricting use of the table to those end users assigned the task of changing defaults.
TheAceMan said:
[blue]The idea is: the forms that use any of the defaults from the table, will load the defaults in the OnLoad event.[/blue]
Changing the defaults simply calls for another form to interface with the table.

Below is a common function you can use to read/write values to/from the table.
Code:
[blue]Public Function DefVal(FieldName As String, IO As Boolean, Optional NewVal)
   'IO = True = Write
   'IO = False = Read
   Dim db As DAO.Database, rst As DAO.Recordset
   
   Set db = CurrentDb
   Set rst = db.OpenRecordset("DefaultTableName", dbOpenDynaset)
   
   If Not rst.EOF Then
      If IO Then
         rst.Edit
         rst(FieldName) = NewVal
         rst.Update
      ElseIf Not IsEmpty(NewVal) Then
         DefVal = rst(FieldName)
      End If
   End If
   
   Set rst = Nothing
   Set db = Nothing
    
End Function[/blue]
The code requires [purple]Microsoft DAO 3.6 Object Library[/purple] to run. To [blue]check/install[/blue] the library, in any code window click [blue]Tools[/blue] - [blue]References...[/blue] In the listing find the library and [blue]make sure its checked.[/blue] Then using the up arrow, [purple]push it up as high in priority as it will go[/purple]. Click OK.

Thats about it except that the above forces some kind of rollout of the frontend to incoorperate the new changes.

[blue]Your Thoughts! . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Hi TheAceMan1,

This is what I ended up using on the form control.
I created master tables for all the fields on the form that'll need to have a default value.

nameofcontrol.DefaultValue = DLOOKUP("LaborRate","tblLaborRates","[EffectiveDate]=#" & DMAX("EffectiveDate","tblLaborRates","[EffectiveDate]<=#" & Date() & "#") & "#")

The DMAX finds the maximum EffectiveDate in the table that is <= today, and the DLOOKUP uses that date to get the matching rate for that date.


Tested it and once you start entering the new record, it pulls the value for the max date.


Thanks! I'll test your code and check it out though!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top