Filter a Popup Form with Subform

namu

Registered User.
Local time
Today, 11:41
Joined
Dec 30, 2014
Messages
26
Hi All,

I have a continuous Form [Letter Log - All] with "LetterNo" field as the primary key. What i want to do is click the "LetterNo" and a filtered pop up form with subform should appear based on what has been clicked. But i don't have luck doing that. The name of the main form is "LetterLog" and its subform control name is "LetterLogSub"

here is what i did.

Code:
Private Sub LetterNo_Click()

'DoCmd.OpenForm "LetterLogSub", acNormal, , "LetterNo = " & Me.LetterNo, acFormEdit, acDialog <-- this one works but without the subform
'DoCmd.OpenForm "LetterLog", acNormal, , "Forms!LetterLog!LeteterLogSub.Form.LetterNo = " & Me.LetterNo, acFormEdit, acDialog

'DoCmd.OpenForm "LetterLog", acNormal, "LetterNo", "me.LetterLogSub.Form!LetterNo = " & Me.LetterNo, acFormReadOnly, acDialog


DoCmd.OpenForm "LetterLog", acNormal, "LetterNoFilter", "Forms!LetterLog!LetterLogSub.form!LetterNo = " & Me.LetterNo, acFormEdit, acDialog

End Sub

can somebody please guide me? I already checked this link //access.mvps.org/access/forms/frm0031.htm but i don't understand it.

Thank you in advanced. :)
 
if your LetterNo field is numeric:

DoCmd.OpenForm FormName:="LetterLog", wherecondition:="[LetterNo] = " & Forms![Letter Log - All]!LetterNo, AcWindowMode:=acDialog


if text:

DoCmd.OpenForm FormName:="LetterLog", wherecondition:="[LetterNo] = '" & Forms![Letter Log - All]!LetterNo & "'", AcWindowMode:=acDialog
 
Hi arnelgp,

thank you for you reply, the letterno is a autonumber field so i tested your code and it opens the form/subform however, it does not apply the filter. it is still showing the first record of the form with subform.
 
if its not much for you can you upload your db.
 
try this and review the code in main form and your pop-up form.
 

Attachments

Hi arnelgp,

Thank you very much because this is exactly how i want it to be!

Would you mind if you give me some overview of what the Me.ID means on the last part of the onclick command? I also noticed that you made an IF statement on the onload event of the main form.. I will really appreciate it.

Thank you once again. Cheers!
 
the last part of the docmd.openform is a parameter. all forms receives parameter through me.OpenArgs.

DoCmd.OpenForm(FormName, View, FilterName, WhereCondition, DataMode, WindowMode,
OpenArgs)
 

Users who are viewing this thread

Back
Top Bottom