By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
463,115 Members | 582 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 463,115 IT Pros & Developers. It's quick & easy.

how two forms can be synchronized

P: 4
Hi All
form1: table A with table B with many 2 many relations
form2 table A and table C with many 2 many relations

Can both forms be synchronized, e.g. when a record in form1 table A is selected form2 table A goes to the same record
1 Week Ago #1
Share this Question
Share on Google+
7 Replies

cactusdata
Expert 100+
P: 122
Yes. Set the Filter of form2 from the OnCurrent event of form1:

Expand|Select|Wrap|Line Numbers
  1. Dim Form As Form
  2.  
  3. Set Form = Forms("form2")
  4. Form.Filter = "ID = " & Me!ID.Value & ""
  5. Form.FilterOn = True
where ID is the primary key of table A.
1 Week Ago #2

twinnyfo
Expert Mod 2.5K+
P: 3,542
gabril16,

Welcome to Bytes!

Are these two, separate, independent forms? Or is this a case of a form with a subform?

CactusData's solution will certainly work for two independent forms, but only if both forms are open.

If you have a subform configuration, simply establish the Parent Child relationship in the Subform's properties.

Hope that hepps.
1 Week Ago #3

P: 4
Option Compare Database

Private Sub Form_Current()
Dim Form As Form
'form2=fmClientLogDtls2
'logDtlsID is primery key of table A
Set Form = Forms("fmClientLogDtls2")
Form.Filter = "ID = logDtlsID" & Me!ID.Value & ""
Form.FilterOn = True
End Sub
1 Week Ago #4

P: 4
Can you please advice what's wrong with my code?
1 Week Ago #5

twinnyfo
Expert Mod 2.5K+
P: 3,542
gabril,

Please tell us what is not working with your code. Are you receiving an error? If so, at what line?

Part of the problem may be in declaring a variable with the name of "Form" which is usually a reserved word and the DB may be getting confused by it.

Plus, it would be very helpful to know more about the structure of your tables/forms, as to whether you have a subform, or two open forms.

Thank you.
1 Week Ago #6

cactusdata
Expert 100+
P: 122
Try this:

Expand|Select|Wrap|Line Numbers
  1. Dim Form As Form
  2.  
  3. Set Form = Forms("fmClientLogDtls2")
  4. Form.Filter = "logDtlsID = " & Me!logDtlsID.Value & ""
  5. Form.FilterOn = True
1 Week Ago #7

P: 4
Thank you all
Thank you cactusdata...it's working perfectly
5 Days Ago #8

Post your reply

Sign in to post your reply or Sign up for a free account.