Link related forms

dealwi8me

Registered User.
Local time
Today, 19:43
Joined
Jan 5, 2005
Messages
187
I have two tables (table1,table2) with one-to-many relathionship between them.
Form1 has table1 as Record source and form2 has table2 as record source. I connect these two forms with a command button.
How can i get to form2 only the records that related to form1 record?

Thank you in advance:)
 
RuralGuy said:
Pass the information in the OpenArgs parameter.

any examples? :confused:

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

Post your cmdButton click code and describe what information you want to pass and where it is located.
 
Last edited:
this is the code...but i can't make it work... is there anything else i must do at form2?

Private Sub cmdEnterFields_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form2"

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

End Sub
 
That should work if [IdNo] is numeric. If it is "not working" then what is it doing? Are you getting an error, too many records, not enough records?
 
yes the IdNo it's numeric.

At form2 i get all the records of table2 without considering the IdNo as a filter.
 
Is Form2 based on a query or a table? Does it include the [IdNo] field? Sorry if that is a simple question but I have to cover the bases.
 
form2 is based on table2 and table2 has IdNo as a field.
Table1 has idNo as well and is linked to table2 with one-to-many relationship.

form1 is based on table1.

i hope that helps...
 
Insert this diagnostic in your code:
Code:
stLinkCriteria = "[IdNo]=" & Me![IdNo]
[B]MsgBox "stLinkCriteria = [" & stLinkCriteria & "]"[/B]
DoCmd.OpenForm stDocName, , , stLinkCriteria
That should show you what is being passed as a Where clause.

Edit: That was stupid of me! :o Make that line:
MsgBox "stLinkCriteria = >>" & stLinkCriteria & "<<"
 
Last edited:
I found what the problem was. I didn't assign at form2.idno the form1.idno and that's why i couldn't get the right results.

Thank you so much for your help :)
 

Users who are viewing this thread

Back
Top Bottom