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

Code works in 97, but not 2000

Status
Not open for further replies.

milte

Technical User
Jan 30, 2002
20
US
Hello everyone,

I have a form that sorts records. I have a button on that form that after the person finds the record he wants, he can click the button and go directly to that record. This program works fine in '97 version, but when I convert it to 2000, the filtered form comes up blank. I've also opened it up in 2000 without the conversion and get the same results.

Here's my code:

Private Sub Number_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmAddDel"

stLinkCriteria = "[Number] = Forms![frmApplicants]![Number]"

DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.RunCommand acCmdApplyFilterSort

Exit_Number_Click:
Exit Sub

Err_Number_Click:
msgbox Err.Description
Resume Exit_Number_Click

End Sub


Thanks for any help you can give me.

Milt
 
I cannot tell you why this would not work in 2000 but my bet is the syntax of the Criteria is the problem.

I would suggest an alternative approach. The form you want to open must be bound to a table or query. If it is bound to a table make up a query that is identical to the table. Now put in the "Criteria" section of the corresponding field "Number" on the query this same Forms![frmApplicants]![Number]. Now open the new form and the criteria will pass through directly via the query. This might get you out of the problem in 2000.

A second thought might me to change the name of the control on the two forms so they are not the same as the field on the table. Name the control on the forms txtNumber just to avoid any confusion in refering to them in script. This is usually not a problem but we have seen this odd behavior in criteria of SQL statements when we have a table field and a form control or report control with the same name.

Hope this helps.

Moe Dweck
Data-trieve, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top