Form with selector

D

Dan

I have a table in Microsoft Access to store records with
approx 10 fields (i.e. FirstName, LastName, Address,
etc.). I would like to design a form to display these
records in the following way. The form would consist of
two sections, the top section and the bottom section.
The top section would be used to display a single record
with all fields in a columnar (form) fashion. Now the
bottom of the form would display all of the records in a
datasheet style. Here is where I am stuck... In the
bottom portion that is displayed as a datasheet, I want
to select a record and then have that record displayed in
the top section of the form in the columnar (form)
portion. I am unable to have the record that is selected
in the bottom portion display in the top portion. Any
suggestions? Thank you very much.

--Dan
 
A

Andrew Smith

Which version of Access are you using? (There is a fairly easy way of doing
this in Access 2000 or higher).
 
A

Andrew Smith

OK. Here is how I would do this:

1. Design two separate forms - one to be your top section and the second
your bottom section.
2. Create a third form, and add the first two as subforms. Give the the
subform controls meaningful names - eg subDetail and subDatasheet.
3. Enter the following code in the form's open event:
Set Me.subDatasheet.Recordset = Me.subDetail.Recordset

This should give the effect you're after.
 
A

Andrew Smith

The code should say

Set Me.subDatasheet.Form.Recordset = Me.subDetail.Form.Recordset
 
A

Andrew Smith

Dan,

Perhaps I did not give quite enough information if you're not used to using
VBA (apologies if you've done this correctly). To enter the code:

- open the form's property sheet.
- click the "Event" tab and find the load event.
- select "Event Procedure" from the drop down list, then click the ellipsis
(...) next to the field box. This will open up the VBA editor.
-enter the code in the vba editor between the lines "private sub ..." and
"end sub".
- close the VBA window.

There was an error in my code that I have corrected in a separate message -
it should read:

Set Me.subDatasheet.Form.Recordset = Me.subDetail.Form.Recordset
 
A

Andrew Smith

I thought that might be what you were doing. You need to set the property to
"Event Procedure" and then enter the code in the VBA window. I've explained
this in more detail in another message.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top