Enabling/Disabling Menus from Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I would like to be able to substitue part of the following command using
information from a recordset value. I can't seem to get it to work due to
proper quotes in the syntax. Can anyone help me out?

I currently use:
CommandBars("HRMenu").Controls("User Admin").Visible = True

I would like to replace the "User Admin" with a value that comes from my
recordset something like...
CommandBars("HRMenu").Controls(rst!ObjectName).Visible = True

I am getting a "Type mismatch" error when I try to use the version with the
reference to the recordset. I think it's because of inproper quotations but I
don't know how to do it correctly.

Thanks in advance for your help!
 
in message:
I would like to be able to substitue part of the following command using
information from a recordset value. I can't seem to get it to work due to
proper quotes in the syntax. Can anyone help me out?

I currently use:
CommandBars("HRMenu").Controls("User Admin").Visible = True

I would like to replace the "User Admin" with a value that comes from my
recordset something like...
CommandBars("HRMenu").Controls(rst!ObjectName).Visible = True

I am getting a "Type mismatch" error when I try to use the version with the
reference to the recordset. I think it's because of inproper quotations but I
don't know how to do it correctly.

You might try setting the recordset value to a string first.
Something like so (untested):

Dim strControl As String

strControl = rst!ObjectName

CommandBars("HRMenu").Controls(strControl).Visible = True
 
Hi Jeff,

That did the trick. Although the recordset value is a string value, it must
not recognize it that way so this did the trick. Thanks for your help
 
in message:
Hi Jeff,

That did the trick. Although the recordset value is a string value, it must
not recognize it that way so this did the trick. Thanks for your help

Excellent, glad I could help.
Good luck with your project.
 
Back
Top