form in datasheet view, detailing a some of the fields from each record. How can I click on the one record in the datasheet and open a form with complete details of this record?
Printable View
form in datasheet view, detailing a some of the fields from each record. How can I click on the one record in the datasheet and open a form with complete details of this record?
Have a look at the Where part of the DoCmd.OpenForm method in the help file. It allows you to pass values into an opening form in order to filter to a specific record.
If you have a table with 10 columns and a continuous form with only 2 or three of it (let's call them C1, C2, C3, and a form frm_mainform) and let say C1 is the key column, simply edit C1's ON CLICK property and create even a macro or a VBA code like docmd.openform "MyDetailedForm".
Then create a single form called MyDetailedForm put as many text fields as many you want on it (call then e.g. Cnt1,Cnt2...)and edit the form's ON LOAD property like this:
DIM ds as datasource, rs as DAO.recordset, sql as string
set db = currentdb
sql = "select c1,c2,c3,...cn from table where c1 = " & frm_mainform!c1
set rs = ds.openrecordset(sql,dbopensnapshot,dbseechanges)
then if your controls are text fields
cnt1.value = rs.fields(0)
cnt2.value = rs.fields(1)
and so on
or if you put labels instead
cnt1.caption = rs.fields(0)
cnt2.caption = rs.fields(1)
and so on.
This is my way. Maybe not the best, but it works in any case.
Ooooops.
I made a mistake.
DIM ds as datasource, rs as DAO.recordset, sql as string
incorrect!!!
DIM ds as database, rs as DAO.recordset, sql as string
correct.