Datasheet

RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization
27
Retrieving r is done by looking up the region identifier upon the primary key of the region,
thus
r= forms![input]![region id]
or as an equivalent:
r = Forms("Input").Controls("region id”)
Similar, we may retrieve the district code
d=forms![input]![district id]
or as an equivalent:
r = Forms("Input").Controls("district id”)
Let us say that retrieving n equals retrieving the primary key of the facility that is about to be
created. This may than be simply achieved by
n= Forms.input.Form.[ChildForm].Form.[Details].Controls("PK Facility ID")
with one problem: the primary key is empty, as the record has not yet been created. With MS
Access back-ends, there is a simple trick for enforcing the record to be allocated by simply
calling this line of code ahead
Forms.input.Form.[ChildForm].Form.[Details].Controls("Regulatory Authority
Number")=" "
Please note that a blank is quoted at the end of above statement. This is just like typing a
blank in the field [Regulatory Authority Number]. This makes MS Access allocate a new
record and thus create a primary key, which we may then use. Please note that this does not
work on SQL Servers, as they usually generate primary keys only after successful
transactions.
By default, the RAN function is disabled by writing
BuildFacilityRAN = ""
Exit Function
So the final code of our facility RAN function will then have this appearance:
Public Function BuildFacilityRAN()
Dim r
Dim d
Dim n
r = Forms("Input").Controls("region id”)
If r <> "" Then r = "-" & r
d = Forms("Input").Controls("district id”)