Cannot pass field value between ADP forms

  • Thread starter Thread starter CSDunn
  • Start date Start date
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
 
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
 
Back
Top