Wherecondition in openform

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

Guest

I have used the code below to open the form 'frm_prod_appr_comments' when the
field is dbl clicked and have it display the contents of the field that was
dbl clicked. I have tried using the wherecondition in the openform command,
but it filters the opened form to just a new record and does not link it to
the record that was active. Can anyone see where I have gone wrong?

Private Sub APPRAISAL_COMMENTS_DblClick(Cancel As Integer)
On Error GoTo Err_open_frm_prod_appr_comments_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim appid As String
Dim appid1 As String


stDocName = "frm_prod_appr_comments"
appid =
"Forms!Range_Form1.product_form1_new_one.PRODUCT_APPRAISAL_FORM.Form!APPRAISAL_ID"
appid1 = "Forms!frm_prod_appr_comments!APPRAISAL_ID"
stLinkCriteria = (appid1 = appid)
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_open_frm_prod_appr_comments_Click:
Exit Sub

Err_open_frm_prod_appr_comments_Click:
MsgBox Err.Description
Resume Exit_open_frm_prod_appr_comments_Click

End Sub
 
hi Chris,
I have used the code below to open the form 'frm_prod_appr_comments' when the
field is dbl clicked and have it display the contents of the field that was
dbl clicked. I have tried using the wherecondition in the openform command,
but it filters the opened form to just a new record and does not link it to
the record that was active. Can anyone see where I have gone wrong? Yes.

appid =
"Forms!Range_Form1.product_form1_new_one.PRODUCT_APPRAISAL_FORM.Form!APPRAISAL_ID"
appid1 = "Forms!frm_prod_appr_comments!APPRAISAL_ID"
stLinkCriteria = (appid1 = appid)
This is a string comparision, which is obviously always False. So your
form filters with a "WHERE False" which will return no records ever,
therefore you're always seeing the new record.

If you like to filter for one specific ID then just use:

stLinkCriteria = "idFieldName = " & _
Forms!frm_prod_appr_comments![APPRAISAL_ID]


mfG
--> stefan <--
 
Thanks Stefan,
Should have in the correct area of help as well.

Stefan Hoffmann said:
hi Chris,
I have used the code below to open the form 'frm_prod_appr_comments' when the
field is dbl clicked and have it display the contents of the field that was
dbl clicked. I have tried using the wherecondition in the openform command,
but it filters the opened form to just a new record and does not link it to
the record that was active. Can anyone see where I have gone wrong? Yes.

appid =
"Forms!Range_Form1.product_form1_new_one.PRODUCT_APPRAISAL_FORM.Form!APPRAISAL_ID"
appid1 = "Forms!frm_prod_appr_comments!APPRAISAL_ID"
stLinkCriteria = (appid1 = appid)
This is a string comparision, which is obviously always False. So your
form filters with a "WHERE False" which will return no records ever,
therefore you're always seeing the new record.

If you like to filter for one specific ID then just use:

stLinkCriteria = "idFieldName = " & _
Forms!frm_prod_appr_comments![APPRAISAL_ID]


mfG
--> stefan <--
 
Back
Top