Replacing Menul values

D

dale

I used some code that I had gotten from a Microsoft Access newsgroup
that seemed to work in Access 2000. I have upgraded to XP and it does
not work anymore. The code is in a module is as follows. Any help is
appreciated.

Public Sub changemenu()
Dim cmd As QueryDef
Dim rcs As Recordset
Set cmd = CurrentDb.QueryDefs("labelmapquery")
Set rcs = cmd.OpenRecordset

Dim cbr As CommandBar
For Each cbr In CommandBars
listbar 1, cbr, rcs
Next cbr

End Sub
Public Sub listbar(Level As Integer, thisbar As CommandBar, rcs As
Recordset)
Dim cbrctl As CommandBarControl
For Each cbrctl In thisbar.Controls
rcs.MoveFirst
While (Not rcs.EOF And Not rcs.BOF)
If cbrctl.Caption = rcs("oldlabel").Value Then
cbrctl.Caption = rcs("newlabel").Value
rcs.MoveNext
Wend
' If the control doesn't have a command bar associated
' with it, then don't print it.
If cbrctl.Type <> 1 And cbrctl.Type <> 2 And cbrctl.Type <> 4
And cbrctl.Type <> 16 And cbrctl.Type <> 18 Then
listbar Level + 1, cbrctl.CommandBar, rcs
End If
Next cbrctl
End Sub
 
V

Van T. Dinh

Check that you have Microsoft Data Access Object (DAO) 3.6 Library and
Microsoft Office 10.? Library included in the References.

If you get error message, please post the error number (if possible), error
message and indicate the line of code that errors out.
 
D

dale

I have them both referenced. I get the following

Run-time error '438'
Object doesn't support this property or method

It happens on the line marked with here*****

Public Sub listbar(Level As Integer, thisbar As CommandBar, rcs As
Recordset)
Dim cbrctl As CommandBarControl
For Each cbrctl In thisbar.Controls
rcs.MoveFirst
While (Not rcs.EOF And Not rcs.BOF)
If cbrctl.Caption = rcs("oldlabel").Value Then
cbrctl.Caption = rcs("newlabel").Value
rcs.MoveNext
Wend
' If the control doesn't have a command bar associated
' with it, then don't print it.
If cbrctl.Type <> 1 And cbrctl.Type <> 2 And cbrctl.Type <> 4
And cbrctl.Type <> 16 And cbrctl.Type <> 18 Then


Here*****
listbar Level + 1, cbrctl.CommandBar, rcs


End If
Next cbrctl
End Sub
 
V

Van T. Dinh

The CommandBarControl does not have the property "CommandBar" AFAIK. I
think you probably want the property "Parent".

It looks like you use recursive call so you have to be careful here also.
 
D

dale

Van,

If I replace the cbrctl.commandbar with cbrctl.parent I get a run-time
error 28 OUt of stack space. If I just put parent I get a run-time error
13 datatype mismatch. Any other ideas?

Dale
 
V

Van T. Dinh

"Parent" seens to be correct there!

I wrote previously that you use recursive calls and this errors indicate
that too many recursive calls are performed. I think this is the problem
you have to think about to make sure recursion is teminated in a small
number of steps.
 
D

dale

Van,

Do you have any other suggestions on how to replace the text on menus
and sub menus. I have a database that the menus need to be one thing for
US clients and a different thing for Canadian clients.

Dale
 
V

Van T. Dinh

Sorry, I don't do much work with Menubars. My applications mostly use
CommandButtons rather than MenuBars.
 

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