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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Filtered Form by Double Clicking Subform

Status
Not open for further replies.

mkallover

Programmer
Feb 6, 2008
88
US
Hi all, I've got a main form containing a subform in datasheet view. I've got one of the fields set up so that when it is double-clicked, the following code runs:

Code:
Private Sub TaskID_DblClick(Cancel As Integer)

DoCmd.OpenForm "frmAddTask", acNormal, "[TaskID] = " & Me!TaskID

End Sub

TaskID is just a autonumber field to ID each individual task record. When the form opens, it always displays the first record in the DB instead of the TaskID of the record I double-clicked on.

Any thoughts on what's up with this? I'd appreciate it.
 
There might be a cleaner way, but this might work:
Code:
Private Sub TaskID_DblClick(Cancel As Integer)

DoCmd.OpenForm "frmAddTask", acNormal, "[TaskID] = " & Me!TaskID
[highlight]Forms!frmAddTask.TaskID.Value= Forms!MainForm.TaskID[/highlight]

End Sub

Of course, that's just taking a stab at it, but without testing it out myself..

--

"If to err is human, then I must be some kind of human!" -Me
 
Oh, and before the line I put in, you might have to set focus to that control first:
Code:
Forms!frmAddTask.TaskID.SetFocus

--

"If to err is human, then I must be some kind of human!" -Me
 
Thanks for the response but that doesn't work either. That might work if the original form wasn't in datasheet mode.
 
Anyone else have a suggestion for this? No matter what I try I can't seem to get it quite right.
 
Stupid stupid. Pay attention to your commas.

Code:
DoCmd.OpenForm "frmAddTask", acNormal, "[TaskID] = " & Me!TaskID

Should be:

Code:
DoCmd.OpenForm "frmAddTask", acNormal,, "[TaskID] = " & Me!TaskID

*bangs head on desk*
 
Yeah, duh to me, too. I should've seen that when I looked! [smile]

Oh well

[blush]

--

"If to err is human, then I must be some kind of human!" -Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top