implicit call to a control in a form???

G

Guest

I have three tables, tbl1, tbl2, tbl3
tbl1 has three fields, one is autonumber primary key.
tbl2, tbl3 have one field each that relates to tbl1,ID field

I have designed an append query that duplicates the record from tbl1, that
the ID is the same as the relatedID displayed on tbl's2 form
(forms!tbl2!relatedID as criteria in the ID column of tbl1).

What I want to do is that I want to make the criterium to take its value
from the active form's control named relatedID, so as whichever form (of
tables 2,3) is open, the query appends the record that has the value of the
opened form's control named relatedID.

what is the expression I should use?

forms(activeform)![relatedID] doesn't work.

thanx in advance
 
G

Guest

Jim -

You are missing a ! from your reference. it should be
forms!(activeform)![relatedID]

HTH
 
G

Guest

You are missing a ! from your reference. it should be
forms!(activeform)![relatedID]

I think not. activeform is not meant to be the name of the form that I want
to get the relatedId from. activeform is a way to set focus to an opened form
in the db (used in a module)

Trying it as you said I get:
"the expression you entered has an invalid . or ! or invalid ()
You may have entered an invalid identifier or typed parentheses following
the null constant"

in a module forms(activeform)![relatedID] first finds the form that is
active on the db (can be any form) and then sets focus to the control named
relatedID in it.
 
J

JohnFol

There is a slight problem with this approach if the query has focus when you
run it. If so, you cannot determine which form had focus. Let's presume the
active form, (whatever it is) has a button that launches the query. The
query then needs to get the relatedID from that form.

In the query add in
GetRelatedID() AS Expr1
In a new module add in

Public Function GetRelatedID() As String

GetRelatedID = Screen.ActiveForm!GetRelatedID

End Function


Hope this explains things ok.

(PS if you try the Screen.ActiveForm in the query I think it fails as there
is no such concept of Screen within SQL)



Jim Tanis said:
You are missing a ! from your reference. it should be
forms!(activeform)![relatedID]

I think not. activeform is not meant to be the name of the form that I
want
to get the relatedId from. activeform is a way to set focus to an opened
form
in the db (used in a module)

Trying it as you said I get:
"the expression you entered has an invalid . or ! or invalid ()
You may have entered an invalid identifier or typed parentheses following
the null constant"

in a module forms(activeform)![relatedID] first finds the form that is
active on the db (can be any form) and then sets focus to the control
named
relatedID in it.
 

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