Open form problem

T

Tony Williams

I have a command button on a form based on a table tblmonth, which when
clicked opens a form to show all data from one table, tblmain, where the
date input by the user, txtmontha, is the date which is in a field
txtmonthlabela, in the table tblmain. BUT I also only want the form to show
companies where the Euro indicator against the company in a compnay table,
tblcompany is set to yes. Here is my code
Private Sub Command2_Click()
On Error GoTo Command2_Click_Err

DoCmd.OpenForm "frmFDA", acNormal, "",
"[txtMonthlabela]=[Forms]![frmsterlingeurocos]![txtmontha] And
[tblCompany]![txtEuroIndicator]=Yes", acEdit, acNormal


Command2_Click_Exit:
Exit Sub

Command2_Click_Err:
MsgBox Error$
Resume Command2_Click_Exit

End Sub
The first part works in that only records for the relevant month but all the
compnaies are shown not just those where the euro indicator is set.

What am I doing wrong?
Thanks
Tony
 
B

Barry Gilbert

You can't directly refer to tblCompany this way. At this point in you
code, it has no relation to the form. This looks like it needs some
kind of join, which will be difficut from the WhereCondition clause.

Is there any reason not to change frmFDA to filter for the company in
its underlying query?

Barry
 
T

Tony Williams

You mean base my form on a query rather than the table? Yes I'll have a look
at that why didn't I think of that :)
Thanks
Tony
 

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