More on forms:

This form shows fields, date and buttons that cause processing: Add Record, Delete Record.

The design version of this form is shown below. Note I removed the grid to see it better.

The form header/footer is put on the form through view. In the header, I have a header and the current date. The data was set up using the expression builder. The control source is set to =Format(Date(),"Long Date"). Common Expressions allows you to choose current date. The format of Long Date gets it in the Format shown.

When you select button from the toolbox, you can then select Record Operations and if you want to be able to add records, you can select Add New Record. When you press next, the options will allow you to pick text for the button (Add Button - my choice) or a picture for the button. The next screen allows you to pick a name for the button to refer to in code. Finish puts the named button on the form. Here are the generated properties:

Scrolling down the properties, you will see the On Click Event with [Event Procedure] entered. When you click on the , you will see the code that goes with this button.

This code was generated automatically. Note, the delete button was generated in the same way.

Note that the form has properties that allow edits, allow deletions, allow additions.

Another version of the form uses pictures on the add button and on the delete button. The add button will move to the end and add a new record. The delete will bring up a warning and if confirmed that you want to delete, the record is removed.

In this form, I have added still more buttons. I have added my own buttons for navigation and I have added a button to find something in the form and a button to print. Note that the small screen below is a result of clicking the find button.

The buttons on this form were created in design by bringing over the button from the toolbox. This takes you into the wizard steps that creates the code. This is an example of the choices in Record Navigation.

Notice that in the form shown, I provided the navigation buttons and I removed the default navigation setup. This is done by clicking on the form button (form selector - shown below with the black rectangle in the middle of the box near the top left) to see the property sheet for the form and setting the navigations buttons to NO.

The next example will deal with setting up a form that incorporates the one-to-many relationship between two tables. This design will have a main form and a sub form. The main form will hold the information from the one side and the sub form will hold the information from the many side. Technically you are creating two forms, but essentially they coexist as one. For this example, I am going to use the contributor/donor (Donor) table as the one side and the contributions/donations (Contribu) table as the many side.

First I went in and selected the Form Wizard and the Donor table. Then I moved over the fields that I wanted. At this point, I clicked the down arrow on the Tables/Queries box and selected the second table that I wanted to use, Contribu. The picture below was taken at this point. It shows the fields from the Donor table already selected, the Contribu table selected under Tables/Queries and the Available Fields from the Contribu table.

I selected all of the fields from the Contribu table next. That means that Selected fields will contain fields from both tables.. In "the real world", I would not have selected Idno because it is already part of the fields selected from the Donor table. However, I wanted it clear how the match was working, so I selected Idno. Since it is selected from both fields you will see Donor.Idno and Contribu.Idno in the Selected Fields list.

The next screen that comes up shows the arrangement of the data. You see the donor information at the top and the contribution information below. The default that is checked is form with subforms and that is exactly what we are trying to do. (The form is below the continued explanation). The next screen asks to select they type of display, the options are tabular and datasheet. I selected tabular. It then asked me to pick a background - I choose a solid color. Finally it gave me a chance to change the titles - I stayed with the defaults.

The results are shown below:

Notice the two scroll bars. The inner scroll bar controls the contributions - they are all shown, but it moves focus from one to another. The outer scroll bar controls the donor and will move to the next donor. Note that when a new donor comes up, the contributions for that donor will be shown. Again notice the repetition of idno. Once you are confident with the system, you can eleminate this since the idno is part of the information shown under donor. This output was entirely created using the wizard. I can now go into design mode and make desired modifications. When I go into design mode I see the main form, I see reference to the Contribu SubForm, but I do not see the actual form. Remember - the subform is actually created as a separate form. Before I move to the subform, I want to move YrFirst up under contact for a little more balance. I can do this in design mode by clicking and dragging. I then moved the word Contribu and the Contribu Subform up a little.

The subform in design mode is shown below. Note that under forms the name is listed as Contribu Subform.

I went in and modified AmtCont to make it a smaller field and then in properties, I changed the format to currency. The numbers now display in currency mode.

It should be noted that using this combined form, you can add a contribution and that contribution will then be made part of the Contribu table. You can also add a donor to the Donor table. In this example, I added a donation to drive 123 on 2/20/00 for $600.00. This contribution is now part of the database.

Idno

DriveNo

DateCont

AmtCont

11111

123

12/5/95

1000

11111

123

12/5/96

1200

11111

124

5/14/96

500

22222

123

5/15/96

500

33333

123

2/20/00

600

33333

124

1/12/94

1000

33333

125

5/5/96

100

44444

123

1/1/96

500

44444

124

5/1/96

1000

44444

125

8/1/97

250