Using forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I just started using access for the first time and was
confused about how to use the data in the tables in forms.
I'm not sure how to set up a form that can take in a
parameter, such as a name, and get it to display
information in a table. Can anyone help me with this?
 
I'll take a stab. Forms are a vary versatile object. They
can either be Bound or Unbound. Bound forms are based on a
table or query. By placing controls on the form that are
bound to the table's fields, when you change or enter a
new value in the form control, the value is stored in the
table.

You can do what you're after at least two ways:

1) Base a form on your table. An easy way is to use the
form wizard, tell it what table and what fields you'd like
to include. It will create the basic Bound form, and
place the form controls bound to the fields you've
selected.

To display a particular record, use Filter By Form on the
Form View toolbar, and enter a value to search for.

2) Another way is to provide an unbound "Selection
Criteria" form. If the field you wish to match can only
have certain values (like a Customer with a unique
CustomerID), you can provide a combo box for your users,
and a command button that opens a second form displaying
the data you're after. This is the more common way for
developers.

The code snippet below uses the value entered in the
selection criteria form, using it as filtering criteria:

Private Sub YourCommandButtonName_Click()
On Error GoTo YourCommandButtonNameErr__Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "NameofYourFormInQuotes"
' See VBA Help on OpenForm. This opens the form
' in Add mode. Other options are available.
DoCmd.OpenForm stDocName, acNormal, , , acFormEdit, ,
stLinkCriteria

Exit_YourCommandButtonName_Click:
Exit Sub

Err_YourCommandButtonName_Click:
MsgBox Err.Description
Resume Exit_YourCommandButtonName_Click

End Sub

HTH
Kevin Sprinkel
 
Back
Top