Filtering records problem

T

trekgoes2malaysia

When opeing a form, I want the control_click routine to filter records
by year. Problem is 'Year' is not a field in the table from which the
form gets its data. I have a dateid in the table instead that links
to another "dates" table where 'Year' can be obtained. Question is how
do I filter records by 'Year' then on a form that links to a table
without the field 'Year'? Below is my code where I tried using a
query to achieve this but because the field year is not part of the
table, i keep getting a parameter prompt for 'Year' when I click on
the control.

Any help is appreciated,
Patrick
******************************************************************
Public Sub WelcomeNext2_Click()
On Error GoTo Err_WelcomeNext2_Click

Dim stDocName As String
Dim stLinkCriteria As String


stDocName = "Datelog"

stLinkCriteria = "[athleteid]=" & Me![AthleteCombo1] & " and " &
"[Year] = " & Me!{Yearpicked]

DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acLast

Exit_WelcomeNext2_Click:
Exit Sub

Err_WelcomeNext2_Click:
MsgBox Err.Description
Resume Exit_WelcomeNext2_Click

End Sub
 
G

Guest

Hi Patrick

Create a query that uses all the fields you need from the table and that
includes the year (by joining to the dates table).

Then base the form on this query instead of the table - go into the
properties of the form - data tab - change Record Source to the name of the
query.

hth

Andy Hull
 

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