Beaucoup de questions!
See below for specific
responses.
-----Original Message-----
Thanks Kevin,
well I guess the example I gave was way too simple
This time, I want to be able to calculate many fields
from a few. For example, I want to be able to fulfill a
whole MS Project DB from a few fields. I want to calculate
them instead of having MS Project doing it. Well, I know
MS Project isn't really complyant with 'Data
Importation'
Many fields have to be fulfilled depending of the values
of other. That's why I would use 'Formula' such as 'IIF'
(not sure. In French, that would be 'VraiFaux',
i.e. 'TrueFalse'. This formula makes a logical test, say
compares 2 dates, then have 2 available results depending
of the test). Do I have to load a 'Sub' in
the 'AfterUpdate Event' of my source control ? What would
the syntax / process look like ? I am a little familiar
with VBA and Excel, but I am not sure about how to insert
a calculated 'value' in a 'Control', using (or not)
formulas.
========================================================
Firstly, let's tackle the idea of a form "control".
Reports also have controls, which have similar properties,
but for clarity let's restrict the discussion to form
controls. Basically, they are a placeholder for data and
include the following types: textbox, combo box, list
box, option group, checkbox, etc. Most can be either
Bound or Unbound (a label is by definition Unbound). If
they are Bound, then what is entered into the control is
automatically stored in the field to which it is bound.
So include bound controls for all of your calculated
fields on your form. The easiest way to do this is to
drag and drop them from the View, Field List box.
@IIF is a VBA function that evaluates a logical statement,
and returns one of two values, such as:
Gender = @IIF([GenderType]="M", "Male", "Female")
Which assigns the result to a variable named Gender.
They can be nested, although I don't know how many
levels. Beyond a simple case, I prefer one of the other
logical VBA constructs, If.Then or Select Case..
If [GenderType] = "M" Then
Gender = "Male"
Else
Gender = "Female"
EndIf
Select Case [GenderType]
Case "M"
Gender = "Male"
Case "F"
Gender = "Female"
Case Else
Gender = "On ne sait pas!"
End Select
Since they depend on more than one field's value, use the
Form's AfterUpdate event to set your calculated fields.
If you wish to do error-checking on what's been entered,
use the BeforeUpdate event, which is called before writing
the changes to the table.
=========================================================
By the way, I am thinking of protecting my datas from the
users except from the interface. I mean I just want them
to access the form, not allowing them to 'edit' the
DB. 'DoCmd.Minimize' would only minimize the DB,
not 'Hide' it. Is there a way ?=========================================================
This is a complex issue in which I'm not expert. I
suggest you post a message specific to it for the MVP's.
=========================================================
And eventually, is this possible to use 'Basic' Access as
a multiuser interface ? I mean I would drop my application
on a shared directory, not using any server application
(such as MS Project Server nor one dedicated to Access). I
would like to use a 'buffer' DB for preventing error from
Updating my DB, and a boolean while writting for
preventing from reading, assuming that the 'write'
operation would take less than a seconde. Is that
possible ?=========================================================
Access is by nature a multiuser application. For multiple
users to use it, they each must have a valid copy of
Access installed, or you must provide a run-time version
of your application. The latter can only be done if you
own the Developer's version, and will require additional
error-checking programming and toolbar building on your
part. A run-time error not trapped by the programmer will
cause an ungraceful exit (avec deux pieds gauches) from
the application, and all functionality you wish the user
to have must be built from scratch on custom toolbars.
Re: a "buffer DB"-I've always done all error-checking at
the control and/or form level, "forcing" the user to enter
valid data. Again, this is a complex issue; I suggest you
post a question specific to it.
Good luck with your project. A vÔtre service.
Kevin Sprinkel
=========================================================