Wherecondition in openform

C

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?

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
 
S

Stefan Hoffmann

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 <--
 
C

Chris

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 <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top