Datasheet subform

rpm

New Member
Joined
Aug 28, 2002
Messages
11
I'm new to Access/VBA so I hope I can expalin what I'm after to experts... I have a datasheet subform that displays one to many records of a table. I would like the user to double-click on one record and a new form opens up to edit the field values on that record. Currently, the form opens up on the last record displayed no matter which record I select...

Any advice is welcomed.
Thanks,
Peter
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi rpm, the trick here is to use an extra control in the main form. Do this:
1. Drag a textbox onto the main form, anywhere. Call it txtKey, and make its Control Source [subformName].Subform![ID_fieldname], where ID_fieldname is the key field in the subform.
2. Now, time to cheat. With the Control Wizards on, drag a CommandButton onto the form. When it launches, select Form operations, Open Form, Matching ... and use txtKey in the main form to match the key field in the other form. Click OK.
3. Try it out: select a record in the subform, click the button, and see how you go. If OK, right-click the Command Button (in Design view), select Properties, and go to the Click event code. Copy this code to the double-click event of the subform, but be careful to match up the control names ofr the error handling.
4. Test out again, by double-clicking the subform. If still OK, go back to Design view and delete the Command Button. Also, set the Visible property of txtKey to False.

Denis
 
Upvote 0

Forum statistics

Threads
1,221,840
Messages
6,162,311
Members
451,759
Latest member
damav78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top