How do I open a specific Access form record by simply clicking on a field in another form record fie

Joined
May 17, 2012
Messages
6
Reaction score
0
I am new to Access but have designed a relatively solid database with my limited knowledge. Now I am looking at creating expressions and/or macros that will automate some of the functions that my volunteers & I need.


I have a Minister's Form that includes a field listing the name of the ministry that particular minister represents. We want to click on that Ministry field and have theMinistry Form open to the corresponding ministry record.


Form 1= FrmMinisters
Field 1= ParentMinName or ParentMinID


Form 2= FrmParentMinistries
Field 2=ParentMinName or ParentMinID


ParentMinID is the primary key for Form 2
ParentMinName is the same value on both corresponding records


I know enough to use the "Event on click" section in properties but don't know enough to create the necessary coding instructions. Can anyone assist me in building a code that will do this?


Thanks!
Melissa
 
Joined
Aug 2, 2012
Messages
2
Reaction score
0
Create a property inside the Ministry Form along the lines of:

private _MinistryID as Integer ' Or whatever type your ID Field is.

public property MinistryID() as Integer ' Same as private declaration.
get
return _MinistryID
end get
set (value as Integer)
_MinistryID = value
' Run a function here to filter and/or bind data using _MinistryID.
end set
end property

Then inside the OnClick Event of your field in the Ministers Form have something like

dim frm as new MinistryForm
frm.MinistryID = ParentMinID
frm.showdialog{}

Hope this helps
 
Joined
May 17, 2012
Messages
6
Reaction score
0
LouisWatson,
Thanks for answering this. I should've taken it down. I actually got an answer similar to yours on another site withiin a couple days of posting.
Sorry to trouble you!
Melissa
 
Joined
May 17, 2012
Messages
6
Reaction score
0
The final coding looked like this:
Private Sub ParentMinID_DblClick(Cancel As Integer)
Dim strCriteria As String
strCriteria = "ParentMinID = " & Me.ParentMinID
DoCmd.OpenForm "FrmParentMinistries", WhereCondition:=strCriteria, WindowMode:=acDialog
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top