When either all horizontal boxes have been covered or the
user simply
decides to move to another horizontal range of boxes, he or she is said to have
created a record. In summary, a record is a series of the same horizontal boxes.
A record is actually represented as a row. The intersection of a column and a
row is called a cell. This means that data is actually entered into cells.
|
By default, if you generate a form based on a table
and intended for data entry, all records would be accessible. When it's
time to add a new record, the user must move from one record to an empty
one. An alternative is to create a form specially made for data entry.
This type of form comes up with empty controls and expects the user to
simply enter the new values.
To create a form for direct data entry, you have many
alternatives. One of the techniques you can use to create a data
entry-only form is as follows:
- Generate a form based on the table that holds the information
- Set its Navigation Buttons property to No and its Data Entry
property to Yes
|
You can also allow the user to open a form for data
entry, that is, to a new record. To do this, you
can call the GoToRecord() method of the DoCmd object. The
syntax of this method is:
GoToRecord(ObjectType, ObjectName, Record, Offset)
The first argument to this method must be a constant
value. In this case, it would be acDataForm. If you are calling it
to act on the current form, you can set this argument to acActiveDataObject.
In this case, you can omit this argument.
The second argument is the name of the form to which
the new record will be added. If the record is being added to the same
form that is making the call, you can omit this argument.
The third argument specifies the action that would be
performed. This argument holds a constant value. In the case of adding a
new record, the value of this argument would be acNewRec.
The last argument has to do with other values of the
third argument.
Here is an example that opens a form named Customers
at a new record:
Private Sub cmdAddCustomer_Click()
DoCmd.OpenForm "Customers1"
DoCmd.GoToRecord acDataForm, "Customers", acNewRec
End Sub
Instead of writing this code, you can use the Command
Button Wizard where you would select Record Operations followed by Add New
Record.
Practical
Learning: Creating a Data Entry Form
|
|
- Open the GCS2 database you created in the previous lesson
- In the Forms section of the Database window, right-click
CleaningOrders and click Save As...
- In the Save Form To text box, change the name to NewCleaningOrder
and click OK
- Right-click NewCleaningOrder and click Design View
- Double-click the button at the intersection of both rulers the
access the Properties window for the form and, in the All tab, change
the properties as follows:
Caption: Georgetown Cleaning Services - New Cleaning Order
Data Entry: Yes
Navigation Buttons: No
- Switch the form to Form View
- Save the form
- Click Customer Phone
- Type 1026882250 and press Tab
- In the Customer Name, type Telanie Marba
- Click the arrow of the Date Left and select a data that corresponds
to June 12, 2002
- Set the Time Left to 10:15 AM
- Set the Date Expected by adding 1 day to the date left
- Set the Time Expected to 8AM
- Click Tax Rate and type 0.0575
- Complete the cleaning order with the following values:
Item |
Unit Price |
Qty |
Shirts |
1.75 |
4 |
Pants |
2.65 |
2 |
Jacket |
3.25 |
1 |
Tie |
2.25 |
5 |
- Close the form
|
|