By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,044 Members | 1,720 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,044 IT Pros & Developers. It's quick & easy.

Global Function Guidance

P: n/a
I need some assistance or advise in composing code for a global
function module or a related one for populating values in text boxes
on reports and forms with a name, actually several different names.
There are over 50 fields in the database requiring name updates and I
need to do this several times. And I don't want to use a table/form to
perform this task.

Here is a bit more information. Yes, I have done the changing of the
values in the text boxes by using a small table and a related form
(optional). An update query would work as well, but here is the spin
on the matter. Since the database has/is/will be compiled as a .mde,
there is obviously no access to the code in the modules, but the
tables and queries are another matter. I do not want to assume the
risk of others accessing or changing the values in the text boxes, so
the logical approach is to use VBA code to achieve it. Anyone's
assistance will be appreciated.

Thanks, Dalan
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Dalan" <ot***@safe-mail.net> wrote in message
news:50**************************@posting.google.c om...
I need some assistance or advise in composing code for a global
function module or a related one for populating values in text boxes
on reports and forms with a name, actually several different names.
There are over 50 fields in the database requiring name updates and I
need to do this several times. And I don't want to use a table/form to
perform this task.

Here is a bit more information. Yes, I have done the changing of the
values in the text boxes by using a small table and a related form
(optional). An update query would work as well, but here is the spin
on the matter. Since the database has/is/will be compiled as a .mde,
there is obviously no access to the code in the modules, but the
tables and queries are another matter. I do not want to assume the
risk of others accessing or changing the values in the text boxes, so
the logical approach is to use VBA code to achieve it. Anyone's
assistance will be appreciated.

Thanks, Dalan

One option is to secure the database so you don't allow users to modify the
relavant table - however if you have not yet implememted user-level security
that might be a bit too much work.
If you want to fix the values in your code, then you could also do that.
For example, as part of a project a customer needed a small selection of
labels to choose from. For various reasons I did not want to add new
tables, so these values were hard-coded and displayed to the user in a
combobox:

strList = strList & """Label"";""Across"";""Down"";""Label size"";"
strList = strList & """J8163"";2;7;""9.90cm x 3.81cm"";"
strList = strList & """L7160"";3;7;""6.35cm x 3.81cm"";"
strList = strList & """L7163"";2;7;""9.90cm x 3.81cm"";"
strList = strList & """L7173"";2;5;""9.90cm x 5.70cm"";"

Me.cboLabelSize.RowSource = strList
Perhaps if I understood the following: There are over 50 fields in the database requiring
name updates and I need to do this several times.

Then I could give some more specific advice.

Fletcher

Nov 12 '05 #2

P: n/a
"Fletcher Arnold" <fl****@home.com> wrote in message news:<bl**********@titan.btinternet.com>...
"Dalan" <ot***@safe-mail.net> wrote in message
news:50**************************@posting.google.c om...
I need some assistance or advise in composing code for a global
function module or a related one for populating values in text boxes
on reports and forms with a name, actually several different names.
There are over 50 fields in the database requiring name updates and I
need to do this several times. And I don't want to use a table/form to
perform this task.

Here is a bit more information. Yes, I have done the changing of the
values in the text boxes by using a small table and a related form
(optional). An update query would work as well, but here is the spin
on the matter. Since the database has/is/will be compiled as a .mde,
there is obviously no access to the code in the modules, but the
tables and queries are another matter. I do not want to assume the
risk of others accessing or changing the values in the text boxes, so
the logical approach is to use VBA code to achieve it. Anyone's
assistance will be appreciated.

Thanks, Dalan

One option is to secure the database so you don't allow users to modify the
relavant table - however if you have not yet implememted user-level security
that might be a bit too much work.
If you want to fix the values in your code, then you could also do that.
For example, as part of a project a customer needed a small selection of
labels to choose from. For various reasons I did not want to add new
tables, so these values were hard-coded and displayed to the user in a
combobox:

strList = strList & """Label"";""Across"";""Down"";""Label size"";"
strList = strList & """J8163"";2;7;""9.90cm x 3.81cm"";"
strList = strList & """L7160"";3;7;""6.35cm x 3.81cm"";"
strList = strList & """L7163"";2;7;""9.90cm x 3.81cm"";"
strList = strList & """L7173"";2;5;""9.90cm x 5.70cm"";"

Me.cboLabelSize.RowSource = strList
Perhaps if I understood the following:
There are over 50 fields in the database requiring
name updates and I need to do this several times.

Then I could give some more specific advice.

Fletcher


Thanks for the reply Fletcher. I assumed that there might be a way to
structure some code on a global basis for doing this. In lieu of that
approach, perhaps constructing an update query could be an
alternative. Any suggestions in that arena? The database will
eventually be compiled in runtime, so that should further limit a
user's access. It's a security measure to ensure specific usage by an
entity. Thanks.
Nov 12 '05 #3

P: n/a

"Dalan" <ot***@safe-mail.net> wrote in message
news:50**************************@posting.google.c om...
"Fletcher Arnold" <fl****@home.com> wrote in message

news:<bl**********@titan.btinternet.com>...
"Dalan" <ot***@safe-mail.net> wrote in message
news:50**************************@posting.google.c om...
I need some assistance or advise in composing code for a global
function module or a related one for populating values in text boxes
on reports and forms with a name, actually several different names.
There are over 50 fields in the database requiring name updates and I
need to do this several times. And I don't want to use a table/form to
perform this task.

Here is a bit more information. Yes, I have done the changing of the
values in the text boxes by using a small table and a related form
(optional). An update query would work as well, but here is the spin
on the matter. Since the database has/is/will be compiled as a .mde,
there is obviously no access to the code in the modules, but the
tables and queries are another matter. I do not want to assume the
risk of others accessing or changing the values in the text boxes, so
the logical approach is to use VBA code to achieve it. Anyone's
assistance will be appreciated.

Thanks, Dalan

One option is to secure the database so you don't allow users to modify the relavant table - however if you have not yet implememted user-level security that might be a bit too much work.
If you want to fix the values in your code, then you could also do that.
For example, as part of a project a customer needed a small selection of
labels to choose from. For various reasons I did not want to add new
tables, so these values were hard-coded and displayed to the user in a
combobox:

strList = strList & """Label"";""Across"";""Down"";""Label size"";"
strList = strList & """J8163"";2;7;""9.90cm x 3.81cm"";"
strList = strList & """L7160"";3;7;""6.35cm x 3.81cm"";"
strList = strList & """L7163"";2;7;""9.90cm x 3.81cm"";"
strList = strList & """L7173"";2;5;""9.90cm x 5.70cm"";"

Me.cboLabelSize.RowSource = strList
Perhaps if I understood the following:
There are over 50 fields in the database requiring
name updates and I need to do this several times.

Then I could give some more specific advice.

Fletcher


Thanks for the reply Fletcher. I assumed that there might be a way to
structure some code on a global basis for doing this. In lieu of that
approach, perhaps constructing an update query could be an
alternative. Any suggestions in that arena? The database will
eventually be compiled in runtime, so that should further limit a
user's access. It's a security measure to ensure specific usage by an
entity. Thanks.

Hi Dalan
I still can't quite see exactly what you are trying to do. Are you talking
about values which will remain constant when the application is run? For
example, you sell the application to a company and want to hard-code the
company name and address so this prints out on forms and reports.
If this is the case, then you could simply create a new module and place the
constants in there, eg:
Public Const g_strComName As String = "Whatever Industries Ltd"
Public Const g_strComAddress As String = "7 Station Road"
Then in the report's open event you could set the labels' captions, eg:
Me.lblComName.Caption = g_strComName

Alternatively have a public function:

Public Function GetConst(strConst As String) As String

Dim strReturn As String

Select Case strConst
Case "ComName": strReturn = "Whatever Industries Ltd"
Case "ComAddress": strReturn = "7 Station Road"
Case Else: strReturn = "Unknown Constant"
End Select

GetConst = strReturn

End Function

So you can set the controlsource of a textbox to be
=GetConst("ComName")
Is this the sort of thing? Or should these be gloabl variables which change
their values a number of times while the apppliaction is running? These
will need to be treated with more caution.
Fletcher


Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.