Select record in datasheet view to display in main form

v.bon

New member
Local time
Today, 18:06
Joined
Aug 29, 2017
Messages
7
I am creating a form which allows a user to enter information about students. On the same form, it also allows the user to enter text into a search box which will run a query and then will display the results of the query at the bottom of the form in a subform (as a datasheet).

I am trying to make the DB detect the location of where a user clicks within the subform and identify which record has been clicked on. I will then be able to assign the record location to a variable. So that the record can be editted.

I understand this has been asked in similar ways before but i havent found them threads useful.

Any help or guidance would be greatly appreciated.
 
You should have unique I'd it autonumber field in your table, so that when a record is clicked you can save this number.
 
How would i find out the value of the unique field from clicking on the record?
 
open your form in design view

add an Unbound Textbox to your Main form.
On its Proerty->Format->Visible: No

name the Unbound Textbox as txtSubFormID

add code to your subform's Current Event
so the Unique ID from your subform will be
put to the Unbound textbox (stsSubFormID):

Private Sub Form_Current()
On Error Resume Next
Me.Parent!txtSubFormID = Me.UniqueID (PK field name or auto number)
End Sub
 

Users who are viewing this thread

Back
Top Bottom