8
Database expressions Creating automation in forms Generating an automatic ID

Database expressions Creating automation in forms

Embed Size (px)

DESCRIPTION

Database expressions Creating automation in forms. Generating an automatic ID. Expressions. Dmax(“Field name”,”TABLE NAME”)+1 # finds the highest value in field from table addss 1 to it Val([FIELD NAME]) # switches datatype to a value Right([FIELD NAME],2) - PowerPoint PPT Presentation

Citation preview

Page 1: Database expressions Creating automation in forms

Database expressions

Creating automation in formsGenerating an automatic ID

Page 2: Database expressions Creating automation in forms

Expressions

=DMax("Val(Right([StudentID],4))","TBL_Students")+1

Dmax(“Field name”,”TABLE NAME”)+1# finds the highest value in field from table addss 1 to itVal([FIELD NAME])# switches datatype to a valueRight([FIELD NAME],2)# gets 2 characters from the right hand side of the field

Page 3: Database expressions Creating automation in forms

Ucase()# switch to uppercaseLcase() # switch to lowercase&””& # concatenation Left([StudentForename],1)&””&Left([StudentForename],1)# returns first letter first name followed by first letter surname

Page 4: Database expressions Creating automation in forms

Generating next ID number• Create a form based on the table that you are

creating a new entry for

• Any fields that make up part of the ID need to be hidden from the user and an unbound field created in its place that the user can enter the data into

• To make the bound forename and surname fields invisible set the visible property to ‘no’, you will also need to do this for the label for these fields

• You will also need to make an unbound field that just generates the next number for IDs – this can be hidden from the user

• The three unbound fields required for this example are highlighted in red

• Make sure all fields are named appropriately so you can refer to them later

Page 5: Database expressions Creating automation in forms

Generating next ID number pt 2

• Using the field you created for finding the next ID number create the default value above• DON’T FORGET TO USE YOUR OWN TABLE AND FIELD NAMES!

Page 6: Database expressions Creating automation in forms

Generating next ID number pt 3

• Set both of your bound first name and surname fields to get their value from the unbound version

• =[UNBOUND FIELD NAME] will automatically fill the field based on what the user enters into the unbound field.

• This allows this information to be saved into the table

• Do the same for both forename and surname fields

Page 7: Database expressions Creating automation in forms

Generating next ID number pt 4

• Set up the default value of the ID field as per the scenario (you may need to work this out by looking at the data)

• Concatenate the various parts of fields together using &””&

• NOTE: the fields referred to will always be the UNBOUND fields

Page 8: Database expressions Creating automation in forms

Generating next ID number pt 5

• Create a macro on the on lost focus property of what ever is the last field the user needs to fill in in order to have all the information necessary for the computer to generate an ID (DO NOT PUT IT ON THE FIRST FIELD, IT WILL NOT WORK!)

• The macro will simply requery the form and update the fields with the information as per the expressions used in the default values

• You should now have generated an ID

• Make sure you read the scenario carefully and study the data so you know what makes up your ID – it will not necessarily be the same as this scenario