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!

Help!!! in Open Form and find specific data to display

Status
Not open for further replies.

NekiQ

Programmer
Feb 24, 2003
6
BG
My 1st form had 2 fields, class and year. I wish to link it to another form through these two fields. I inserted a button which the wizard help me display the next form using the class field. Is there any way that I could change the code which could link to the next form through both the class and year fields?

The code generated by the wizard is:

Private Sub Command15_Click()
On Error GoTo Err_Command15_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Student"

stLinkCriteria = "[Year]=" & "'" & Me![SearchYear] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_Command15_Click:
Exit Sub

Err_Command15_Click:
MsgBox Err.Description
Resume Exit_Command15_Click

End Sub


Thank You very much!
 
you just change the stLinkCriteria to include both conditions (in this example i assumed that the text box containing the class is named SearchClass)

Private Sub Command15_Click()
On Error GoTo Err_Command15_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Student"

stLinkCriteria = "[Year]='" & Me![SearchYear] & "' And [class]='" & Me![SearchClass] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_Command15_Click:
Exit Sub

Err_Command15_Click:
MsgBox Err.Description
Resume Exit_Command15_Click

End Sub

good luck
Erez.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top