Cannot pass field value between ADP forms

C

CSDunn

Hello,
In an Access 2000 ADP using SQL Server 2000 objects for data, I have a form
called 'frmSite' which contains a hidden field called 'Location2' and this
field sits behind a subform called 'frmSiteSub'. I have a button in the
subform that is supposed to open another form main called 'frmMain' and
filter the records by the value of 'Location2' found in 'frmSite'. Both main
forms are based on the same SQL Server 2000 table, and contain the field
'Location2'.

I set up a simple Macro for the OnClick event of a button in the subform
'frmSiteSub' to open 'frmMain'. In the Macro, I have the 'Where Condition'
set up as follows:

[Location2]=[Forms]![frmSite]![Location2]

When I try to click the button to open 'frmMain' with the ADP open under my
domain account (I'm dbo) I get the following message:
"Line 1: Incorrect syntax near'!'". The macro stops, and 'frmMain' never
opens.

When I set up the 'Where Condition' with a hard number instead of
'Location2' as follows:

[Location2]=370

The form 'frmMain' opens up without a problem and shows the correct data.

I've passed field values like this between forms before, but for some
reason, I can't get this to work.

Any ideas?

Thanks!

CSDunn
 
V

Vadim Rapp

C> [Location2]=[Forms]![frmSite]![Location2]

C> When I try to click the button to open 'frmMain'
C> with the ADP open under my domain account (I'm
C> dbo) I get the following message: "Line 1:
C> Incorrect syntax near'!'". The macro stops, and
C> 'frmMain' never opens.

Access passes the whole expression to the sql server, which has no idea about
the form.

Instead of macro, use event procedure:

docmd.openform "frmMain",,,"location2=" & location2


Vadim
 

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