B
Brad Pears
I am attempting to write a very generic routine and can;t quite seem to gewt
one part of it as "generic" as I'd like.
In the code I am referring to a specific "control" which may be differnt
from screen to screen. I am trying to write the code "generically" so that I
can call the same code from any screen.
Here is the line of code....
' Turn the font green to show the current process
Forms![frmPricing]![frmMenuItems].Form.cmdGEFraming.ForeColor = 32768
How could I write a function that uses the mainform name, subform name, and
appropriate command button name (as detailed above) that was passed to it
and then runs the code to actually set the color??
Please note that this is just one line that needs to be generalized. I have
many like this that I would like to have in one function/procedure and just
call it from each form that needs it...
The procedure would be something like this I would think...
' Call procedure to set the appropriate values
Call SetFormValues("Mainformname", "SubFormName", "ControlName",
"ForeColor", 32768)
Sub SetFormValues(strMain as string, strSub as string, strControl as string,
strProperty as string, PropertyValue as variant)
dim StrCommand as string
' Concatenate the string command
strCommand = "Forms![" & strMain & "]![" & strSub & "].form." & strControl &
"." & strProperty & "= " & PropertyValue
' I tried using "runcommand" (as show below) but it gives me a "Type
Mismatch"
docmd.runcommand(strCommand)
end sub
' Now that I have the command string concatenated, how do I run it??
Any help would be most appreciated!
Thanks,
Brad
one part of it as "generic" as I'd like.
In the code I am referring to a specific "control" which may be differnt
from screen to screen. I am trying to write the code "generically" so that I
can call the same code from any screen.
Here is the line of code....
' Turn the font green to show the current process
Forms![frmPricing]![frmMenuItems].Form.cmdGEFraming.ForeColor = 32768
How could I write a function that uses the mainform name, subform name, and
appropriate command button name (as detailed above) that was passed to it
and then runs the code to actually set the color??
Please note that this is just one line that needs to be generalized. I have
many like this that I would like to have in one function/procedure and just
call it from each form that needs it...
The procedure would be something like this I would think...
' Call procedure to set the appropriate values
Call SetFormValues("Mainformname", "SubFormName", "ControlName",
"ForeColor", 32768)
Sub SetFormValues(strMain as string, strSub as string, strControl as string,
strProperty as string, PropertyValue as variant)
dim StrCommand as string
' Concatenate the string command
strCommand = "Forms![" & strMain & "]![" & strSub & "].form." & strControl &
"." & strProperty & "= " & PropertyValue
' I tried using "runcommand" (as show below) but it gives me a "Type
Mismatch"
docmd.runcommand(strCommand)
end sub
' Now that I have the command string concatenated, how do I run it??
Any help would be most appreciated!
Thanks,
Brad