Menu Bar

C

Chris

Hello

Can I do a menu Bar for my projet, I want to add a menu
Add:
Exemple:

Menu1:
Add
Client
Invoice

MEnu2:
Edit
Client
Invoice

When I click in the Add--> Client it 'll open the
frm_client in add mode

When I click in the Edit--> Client it'll open the
Frm_Client in Edit mode


Is it possible to do it

Thanks

Chris
 
L

losmac

Yes, You can.

Here is an example, how to add custom menu.

Function CreteCustomMenu()
Dim cb As CommandBar
Dim ctr As CommandBarControl, ctr_1 As CommandBarControl

DelCustomMenu

Set cb = CommandBars.Add(Name:="ASDFG",
Position:=msoBarTop) 'normal mode
'Set cb = CommandBars.Add(Name:="ASDFG",
Position:=msoBarTop, MenuBar:=True) 'to overide menu
'Set cb = CommandBars.Add(Name:="ASDFG",
Position:=msoBarTop, MenuBar:=True, Temporary:=True) 'to
overide menu and delete on close application

Set ctr = cb.Controls.Add(Type:=msoControlPopup)
With ctr
.Caption = "New..."
Set ctr_1 = .Controls.Add(Type:=msoControlButton)
With ctr_1
.Caption = "Client"
.FaceId = 354
.OnAction = "New_Client"
End With
Set ctr_1 = .Controls.Add(Type:=msoControlButton)
With ctr_1
.Caption = "Invoice"
.FaceId = 322
.OnAction = "New_Invoice"
End With
End With

Set ctr = cb.Controls.Add(Type:=msoControlPopup)
With ctr
.Caption = "Edit..."
Set ctr_1 = .Controls.Add(Type:=msoControlButton)
With ctr_1
.Caption = "Client"
.FaceId = 361
.OnAction = "Edit_Client"
End With
Set ctr_1 = .Controls.Add(Type:=msoControlButton)
With ctr_1
.Caption = "Invoice"
.FaceId = 363
.OnAction = "Edit_Invoice"
End With
End With

Set ctr = cb.Controls.Add(Type:=msoControlButton)
With ctr
.BeginGroup = True
.Caption = "End"
.FaceId = 106
.OnAction = "Close_App"
End With


cb.Visible = True

Set cb = Nothing
Set cb = Nothing
End Function


Sub DelCustomMenu()
On Error Resume Next
CommandBars("ASDFG").Delete
End Sub

Sub New_Client()
On Error Resume Next
DoCmd.OpenForm "Client", , , , acFormAdd
End Sub

Sub Edit_Client()
On Error Resume Next
DoCmd.OpenForm "Client", , , , acFormEdit
End Sub


Sub New_Invoice()
On Error Resume Next
DoCmd.OpenForm "Invoice", , , , acFormAdd
End Sub

Sub Edit_Invoice()
On Error Resume Next
DoCmd.OpenForm "Invoice", , , , acFormEdit
End Sub
 
C

Chris

Thank you for your reply

But from where I vave to call the function createfunction

Thanks you
 

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