menubuttons in addin

  • Thread starter Thread starter stephan querengässer
  • Start date Start date
S

stephan querengässer

hello ng,

i have developed an addin, which contains different functions to modify
access-dbs. these function should be provided in all databases >>menu-addin.
when i start the addin, i call a function which creates a temporary
menu-bar. form these buttons i want to invoke my function.
if i test it in the addin-mdb it works fine. but if i install it as a addin,
it appears a error, that access couldn't find the function which i defined
in the onAction-property of the menu-button. if i invoke my functions
directly in start-procedureof the addin without menu-buttons it works fine
too.
i tried this with ONAction-property:
"=frmSelectTrim"
"=frmSelectTrim()"
"frmSelectTrim"
"frmSelectTrim()"

i tried also to specify the module which contains my functionslike this:

"=[edit].[frmSelectTrim()]"

i'm in state of confusion and need your help.

thx and best regards
/sq

system: xp pro, ms access 2k

code:
Sub start()
Dim BLeiste As CommandBar, BLStElem As CommandBarControl
Dim PpStElem As CommandBarPopup, BLUStElem As CommandBarControl
On Error GoTo HinzufügenNeueMB_Err
' Erstellt eine neue Menüleiste und verankert sie zur Linken.
Set BLeiste = CommandBars.Add(name:="MResultAccessModule", Position:= _
msoBarTop, MenuBar:=False, Temporary:=True)
' Macht die Menüleiste sichtbar.
BLeiste.Visible = True
' Hindert die Benutzer am Verschieben der Menüleiste.
'BLeiste.Protection = msoBarNoMove
' Erstellt ein Popup-Steuerelement auf der Menüleiste und beschriftet es.
Set BLStElem = BLeiste.Controls.Add(Type:=msoControlPopup)
BLStElem.Caption = "Editieren"
' Erstellt zwei Steuerelemente für das Popup-Steuerelement und setzt einige
Eigenschaften.
Set BLUStElem = BLStElem.Controls.Add(Type:=msoControlButton)
With BLUStElem
..Style = msoButtonIconAndCaption
..Caption = "Tel.-Nr. editieren"
..FaceId = 568
..OnAction = "=editTelNumbers()"
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<INVOKE FUNCTION, HERE IS THE
PROBLEM
..Parameter = 1
..BeginGroup = True
End With
Set BLUStElem = BLStElem.Controls.Add(Type:=msoControlButton)
With BLUStElem
..Style = msoButtonIconAndCaption
..Caption = "nicht belegt"
..FaceId = 276
..OnAction = "=MsgBox(""to be continued..."")"
..Parameter = 2
..BeginGroup = True
End With
Exit Sub
HinzufügenNeueMB_Err:
MsgBox "Fehler " & Err.Number & vbCr & Err.Description & vbCr & "Menüleiste
schon vorhanden, bitte einblenden!", vbInformation, "Hinweis:"
Exit Sub

End Sub


Public Function editTelNumbers()
Dim rs As DAO.Recordset
Dim db As DAO.Database
.....
MsgBox rs.RecordCount & " Datensätze bearbeitet.", vbOKOnly, "Hinweis:"

End Function
 
hello ng,
i found out the problem. it's not a problem of menubuttons.
i have added a reference to my addin.mdb (References.AddFromFile
("M:\...addin.mdb")) and it works fine.
access can't find the functions in my addin.mda without this refernce to the
addin.mdb.
but it is only a workaround. it must work without the reference too, because
the functions are still in the addin.mda and its installed and provided in
the addin folder...so, i dont know, why access need this refernce to the
addin.mdb.
for example, if i want to sell it, i can't sell my addin.mdb with the
sourcecode in order to set the reference...

any suggestions?

thx for your help and best regards
/sq

ps: apologize my bad english...



stephan querengässer said:
hello ng,

i have developed an addin, which contains different functions to modify
access-dbs. these function should be provided in all databases
menu-addin.
when i start the addin, i call a function which creates a temporary
menu-bar. form these buttons i want to invoke my function.
if i test it in the addin-mdb it works fine. but if i install it as a addin,
it appears a error, that access couldn't find the function which i defined
in the onAction-property of the menu-button. if i invoke my functions
directly in start-procedureof the addin without menu-buttons it works fine
too.
i tried this with ONAction-property:
"=frmSelectTrim"
"=frmSelectTrim()"
"frmSelectTrim"
"frmSelectTrim()"

i tried also to specify the module which contains my functionslike this:

"=[edit].[frmSelectTrim()]"

i'm in state of confusion and need your help.

thx and best regards
/sq

system: xp pro, ms access 2k

code:
Sub start()
Dim BLeiste As CommandBar, BLStElem As CommandBarControl
Dim PpStElem As CommandBarPopup, BLUStElem As CommandBarControl
On Error GoTo HinzufügenNeueMB_Err
' Erstellt eine neue Menüleiste und verankert sie zur Linken.
Set BLeiste = CommandBars.Add(name:="MResultAccessModule", Position:= _
msoBarTop, MenuBar:=False, Temporary:=True)
' Macht die Menüleiste sichtbar.
BLeiste.Visible = True
' Hindert die Benutzer am Verschieben der Menüleiste.
'BLeiste.Protection = msoBarNoMove
' Erstellt ein Popup-Steuerelement auf der Menüleiste und beschriftet es.
Set BLStElem = BLeiste.Controls.Add(Type:=msoControlPopup)
BLStElem.Caption = "Editieren"
' Erstellt zwei Steuerelemente für das Popup-Steuerelement und setzt einige
Eigenschaften.
Set BLUStElem = BLStElem.Controls.Add(Type:=msoControlButton)
With BLUStElem
.Style = msoButtonIconAndCaption
.Caption = "Tel.-Nr. editieren"
.FaceId = 568
.OnAction = "=editTelNumbers()"
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<INVOKE FUNCTION, HERE IS THE
PROBLEM
.Parameter = 1
.BeginGroup = True
End With
Set BLUStElem = BLStElem.Controls.Add(Type:=msoControlButton)
With BLUStElem
.Style = msoButtonIconAndCaption
.Caption = "nicht belegt"
.FaceId = 276
.OnAction = "=MsgBox(""to be continued..."")"
.Parameter = 2
.BeginGroup = True
End With
Exit Sub
HinzufügenNeueMB_Err:
MsgBox "Fehler " & Err.Number & vbCr & Err.Description & vbCr & "Menüleiste
schon vorhanden, bitte einblenden!", vbInformation, "Hinweis:"
Exit Sub

End Sub


Public Function editTelNumbers()
Dim rs As DAO.Recordset
Dim db As DAO.Database
....
MsgBox rs.RecordCount & " Datensätze bearbeitet.", vbOKOnly, "Hinweis:"

End Function
 
Back
Top