I am one of many who feel that you are taking unnecessary chances by giving
users access to datasheet view in a developed application because their are
so many things they can inadvertently do wrong. I would suggest you create a
Form for your information, and use the WhereCondition argument of the
DoCmd.OpenForm in the AfterUpdate event of the Combo or ListBox.
However, if you feel compelled to use datasheet view, the "acFormDS"
constant in the second argument of DoCmd.OpenForm will open the form in
datasheet view (no matter what Default View you have specified for it).
Here's an example of opening the Customers table from the Northwind Traders
sample database as a datasheet (using an AutoForm created from the Customers
Table as the Form, fmrCustomers).
DoCmd.OpenForm "frmCustomers", acFormDS, , "[CustomerID] = """ &
Me!cboCustomers & """"
The datasheet will show only the single selected record. Note that the
CustomerID in the Northwind Customers Table is a Text field -- that's why
the extra quote marks.
If you want to open it with all the records shown, but located to the one of
interest, create a continuous forms view of the table of interest and in its
Open event put code like the following (this, too, is for a form showing
Northwind Customers, and note that it obtains the CustomerID, criteria, from
the OpenArgs property of the Form):
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "CustomerID = """ & Me.OpenArgs & """"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
But, in the AfterUpdate of the Combo or List Box, use this code to open it
(note if passes the CustomerID, the criteria, in the OpenArgs argument).
DoCmd.OpenForm "frmCustomersContin", acFormDS, , , , ,
Me!cboCustomersContin
Good luck with your project
Larry Linson
Microsoft Access MVP
Larry Linson
Microsoft Access MVP
"Yuki" <am********@thomson.com> wrote in message
news:ci********@odah37.prod.google.com...
I am trying to find out if I can have a specific record that has been
selected in a list box be opened in datasheet view. I can't seem to
find where this can happen or what I need to use to make it happen?
Does anyone have any ideas? My list box is currently tied to an option
group so that they can sort the list box in order of how they want to
search for certain records. It is a maintenance form. I want the user
to be able to select the record and perform maintenance on it and then
have it refreshed in the form once complete. Is this possible? Can
someone direct me on how to start at least being able to select the
record?