Open a form using a list

  • Thread starter Thread starter Verver
  • Start date Start date
V

Verver

Hi,
I did this thing before, however at the moment I simply can't remember how.
I want to open the form using a command button at a specific record that
will be selected by me in a list.
In Office 2007 the list has a pop-up small button that automatically opens a
form. It is ok- I can use that too- but the problem is that I need it to open
another form.
So, in any case, both of the options are good- I just really need you to
help me.
Thank you in advance.
 
Hi Verver,
You can use DoCmd.OpenForm to open another form.
To open it at a particular record, you need to supply a unique key - usually
the primary key of the recordsource of that form.
Here is an example for a customer form where the primary key field is
CustomerID.

DoCmd.OpenForm "frmCustomer", , , "[CustomerID] = " & lngCustomerID & ""

The value of lngCustomerID comes from your list.
If your list is in a combo box, the lngCustomerID is the value of the
combo - like this.

If Not IsNull(Me.cboCustomer) Then
DoCmd.OpenForm "frmCustomer", , , "[CustomerID] = " & Me.cboCustomerID &
""
End If

If your primary key is a text data type, use
"[CustomerID] = """ & Me.cboCustomerID & """"


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Back
Top