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

Synchronize two forms on more than one criteria: VBA pro needed!!! 1

Status
Not open for further replies.

Lreader

Technical User
Jul 27, 2000
13
CA
I have to synchronize a form and a subform on more than one criteria.

I use the code below which was in the " northwind database sample " provided with Access and I modified it for my purpose.

This sample code is based on an unique criteria. I need to synchronize on 3 fields(or 3 criterias). I suppose I will need 2 additionnal variables (SynCriteria1 and SynCriteria2). If I need 2 more variables, I suppose I have to modify the line "DoCmd.OpenForm strDocName,,,SynCriteria" to add theses variables but I don't know how to do that.

Private Sub MySub_DblClick(Cancel As Integer)

Dim strDocName As String, SynCriteria As String
Dim SynCriteria1 As String, Dim SynCriteria2 As String

If IsNull(Me![MyField]) Then
Exit Sub
Else
strDocName = "MySubform"
SynCriteria = "[MyField] = forms![MyForm]![MyField]"
SynCriteria1 = "[MyField1] = forms![MyForm]![MyField1]"
SynCriteria2= "[MyField2] = forms![MyForm]![MyField2]"

DoCmd.OpenForm strNomDoc, , , SynCriteria ???and here I am not able to complete...

End If

End Sub
 
The variable synCriteria represents an SQL Where clause without the word Where. You will only need one variable. But you will sets value as such...

synCriteria = "[MyField] = '" & Forms![MyForm]![MyField] & "' AND " _
& "[MyField1] = '" & Forms![MyForm]![MyField1] & "' AND " _
& "[MyField2] = '" & Forms![MyForm]![MyField2] & "'"

Good luck ... B-) ljprodev@yahoo.com
ProDev
MS Access Applications
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top