Syntax question(S)

B

Bill

I have a situation wherein one of a form's
(frmSermonSelect) command buttons
calls a sub in a general module. The On
Click event of the command button calls
the sub in the general module and passes
the name of the command button's control

I have two problems:

1) In the segment of code below, I hard-coded
the name of the control (cmdSManager) because
I couldn't figure out the syntax in using the
variable name "cmdName", as declared in the Sub
statement:

2) It seems I have to "repaint" the calling form
in order for the color and caption changes to
appear to the user. The syntax you see below
is wrong, but I don't know what it ought to be.

Public Sub SermonMgr(Optional cmdName As String)
..
(snip)
..
If Not IsMissing(cmdName) Then
Forms!frmSermonSelect.Controls!cmdSManager.ForeColor = ForeColorBlue
Forms!frmSermonSelect.Controls!cmdSManager.Caption = "Copying Sermon to
Back-up"
Forms!frmSermonSelect.Controls!cmdSManager.Repaint
End If
..
(snip)
..
 
B

Bill

Got the second question figured out.
(Over complicated that one)
Forms!frmSermonSelect.Repaint
 
B

Bill

Fumbling with the syntax of the 1st issue was
a smoke-screen, as the problem lie elsewhere.

Forms!frmSermonSelect.Controls(cmdName).ForeColor = ForeColorBlue

Works just fine, and is how I'd coded it to
begin with............SIGH!

Bill
 

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