July 7, 2005 at 7:43 am
Hi,
Sorry to bother you guys again, but I can't figure this out nor find my answer online.
I'm trying to update the value of one of my controls using VBA using the following code:
Where SourceForm is the name of the form that has the fkClientID control on it (there are several), and ID is the ID of an item in a combo list (that has just been added in code).
I can't seem to change the value of any controls inside an Eval function. What am I doing wrong. I can change other properties of controls, just not the value property!
Thanks in advance.
Aaron
July 7, 2005 at 8:20 am
Why can't you use this syntaxe? : Form_FormName.fkClientID = id
July 7, 2005 at 8:29 am
Because for other reasons I passed the FormName in as a string. Maybe I didn't have to do that. Here's why I did:
DoCmd.Close acForm, "MainFormProps"
For the former I can see that I could have used a Form variable instead, and then used the syntax you suggested.
For the latter case I can only see that a string is possible, so that SourceForm could be any number of values such as "MainFormProps", "MainFormOpps", "frmActiveProposals" etc., and
DoCmd.Close acForm, SourceForm
would always work.
Do you know of a way to turn a form variable into a string, such as the .ToString method available in .NET?
Thanks.
Aaron
July 7, 2005 at 8:34 am
You can always do this :
Dim MyForm as Access.Form
set MyForm = Application.Forms("FormName")
MyForm.FkClient = SomeValue
...
July 7, 2005 at 11:53 am
Genius!
Thank you!
Aaron
July 7, 2005 at 11:58 am
It's late binding but at least it works .
July 8, 2005 at 2:58 am
why not just
forms("Formname").FkClient = someValue
save yourself some lines of code
martin
July 8, 2005 at 6:59 am
I tried this one but it failed...
Also he said that he wanted to do more than one operation on the form... so it's faster to set it to a variable than to go through the key names collection each time.
July 8, 2005 at 9:26 am
It is always better to pass the correct type to the function. IT allows more control over what you are doing. You can always convert values to the datatypes you need in many cases.
function MyFunction(byRef oForm as Form) as boolean
docmd.clos acForm, oForm.name
myFinction = true true
end function
Kindest Regards,
David
** Obstacles are those frightening things that appear when we take our eyes off the goal. **
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply