Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onclick from subform datasheet to detail form

Status
Not open for further replies.

00trav

Technical User
Mar 6, 2006
8
US
I have a search form that has a subform datasheet that displays the results, the results are only the unique id, and several other identifing fields, so the user can find the specific records.

I would like to make it so that when a user double clicks on any cell of the data sheet it opens the detail form for the record. I don't know where to start. This is the first time i am working with scripting and multiple records in a datasheet, normally i just have me![PPID] as the record id, but i can't get the macro to go the the specific record it only opens the form,

i am sure there is probably a way to do it in VB, any ideas.
 
Try:
On the onclick event of your field/cell try:

Dim stDocName As String
Dim stLinkCriteria As String
If Me![PPID] <> "" Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
stDocName = "NAMEOFYOURDETAILFORM"

stLinkCriteria = "[PPID]=" & Me![PPID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Else
MsgBox "blank record selected"
End If
 
To add to ssatech's solution. Lets say you have several controls in the datasheet. Modularize the solution by
by defining the sub and then calling the sub routing from each control's click event.

In each control' click event:
call gotoDetails

Then you can write the code once

public sub gotoDetails()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "NAMEOFYOURDETAILFORM"
stLinkCriteria = "[PPID]=" & Me![PPID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

The above assumes PPID is not a string. If it is

stLinkCriteria = "[PPID]= '" & Me![PPID] & "'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top