Help with append query (1 Viewer)

Niniel

Registered User.
Local time
Today, 00:21
Joined
Sep 28, 2006
Messages
191
Hello,

Could somebody please tell me how to write my Where statement without specifically mentioning the exact name of the parent form?

This is what I have right now:
WHERE (((tblOptions.OptionsID)=Forms!frmBrowseApplications!sfrmOptions!OptionsID));

It works, but I'd like to get rid of "frmBrowseApplications". And "sfrmOptions" as well if possible. I've been experimenting with "parent" and "me", but either that can't be done or I just haven't hit the jackpot yet.

Thank you.
 

KeithG

AWF VIP
Local time
Yesterday, 22:21
Joined
Mar 23, 2006
Messages
2,592
You have to reference the form and subform so access knows which control contains the value for the criteria.
 

Niniel

Registered User.
Local time
Today, 00:21
Joined
Sep 28, 2006
Messages
191
So if I understand you correctly, I *have* to provide the complete path to the control, and shortcurts like "me.textbox" won't work?
 

KeithG

AWF VIP
Local time
Yesterday, 22:21
Joined
Mar 23, 2006
Messages
2,592
Correct the keyword me will only work in the class module behind a form or report.
 

Niniel

Registered User.
Local time
Today, 00:21
Joined
Sep 28, 2006
Messages
191
That is too bad.
Oh well, thank you for clarifying that for me.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 06:21
Joined
Sep 12, 2006
Messages
15,709
niniel,

what you could do instead of referring to forms, is to save the value in a global variable and get it from there.

------------
in a module define a variable and a function to read it

eg

public myvar as string

function readmyvar() as string
readmyvar = myvar
end function

now in your form, set the variable myvar

and in your query, instead of the forms! etc syntax, you can read the variable retrieving function (you have to do it like this, becuase access cant use the variable directly)

instead of the forms! syntax put =readmyvar() - the brackets are necessary.
 

Niniel

Registered User.
Local time
Today, 00:21
Joined
Sep 28, 2006
Messages
191
Oh, that's a neat idea, thank you! I shall certainly give it a try.
 

Users who are viewing this thread

Top Bottom