problem with strlinkcriteria

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi all,
I have to forms"expense reports by patient" and "invoice register"

i want to creat a button in the form" expense reports by patient" that will
open the other form"invoice register" and show only data for the same patient.
in the form"invoice register" there is a subform"invoice details" where i
enter patient name and other inv details.
so i want this form to show those records that belongs to this patient "in
the subform"

i have tried this way but not succeeded.

strDocName = "INVOICE REGISTER"
strLinkCriteria = "Forms![INVOICE REGISTER]![invoice
details].Form.[PATIENT]= FORMS![Expense Reports by patient].form.[PATIENT]"
DoCmd.OpenForm strDocName, , , strLinkCriteria

any one can tell me what is the problem with this strlinkcriteria?
 
Does the form "invoice register" bound to a table that holds the PATIENT
field, if you do then use this criteria

strLinkCriteria = "[PATIENT]= '" & [PATIENT] & "'"

Adn in the "invoice register" form, link the sub form to the main form using
the child and parend properties
 
If patient is a control on main form:
stLinkCriteria = "[PATIENT]='" & Me![PATIENT] & "'"

If patient is a control on subform:
strLinkCriteria = "[PATIENT]='" & Me![Expense Reports by
patient].Form![PATIENT] & "'"

Brian
 
thank you for response.
the control "patient" is a field in the main form "expense reports by patient"
there is another field "patient"in the subform"invoice details"wich is in
the main form"invoice register" each main form is bound to diffrent table.
 
Well, the where condition in the Open Form command line apply to the main
form, and not to the sub form.

If the "INVOICE REGISTER" Open from the form "expense reports by patient"
only, and this form is stil loaded, ten on the RecordSource of the sub form
you can add the criteria

Select * From TableName Where [PATIENT]= FORMS![Expense Reports by
patient].form.[PATIENT]
======================
If that not the case, pass the PATIENT field using the OpenArgs

DoCmd.OpenForm strDocName, , , , , ,Me.[PATIENT]

On the Load event of the INVOICE REGISTER form write

Me.[invoice details].form.RecordSouce = "Select * From TableName Where
[PATIENT] = '" & me.OpenArgs & "'"
Me.[invoice details].Requery
======================
 
Back
Top