Dim frm As Form
Dim btn As CommandButton
'
DoCmd.OpenForm "form1", acDesign
Set frm = Forms!Form1
Set btn = frm!command0
'
btn.Section = acHeader
but it is read only so you cannot set it in code.
The only way I can think to do it is to delete the button and then insert it in the header, this would (I think) mean deleting the code behind it and recreating that as well, if I have a spare 10mins today, I will try it.
But why do you want to do this?
Regards
Ken Reay
Freelance Developer
kenneth.reay@talk21.com
Aint gonna happen unless you want to use the API and some pretty hefty code. A control's 'section' property is read-only at runtime and you'd have to change it from acFooter to acHeader to move the button to the top, otherwise all you can do is move it around in its current section. Your best bet is to add two buttons that call the same function and toggle their visiblity as needed.
If your users can open the form in design view you can make this kind of change programmatically, but design view is usually off limits to end users if permissions are set up properly.
You can 'move' the button, as I suggested by deleting and recreating.
Public Sub moveit()
Dim frm As Form, ctlNew As Control, btn As CommandButton, btnNew As CommandButton
Dim strName As String
' Create new form and get pointer to it.
DoCmd.OpenForm "Form1", acDesign
Set frm = Forms!Form1
Set btn = frm!Command0
strName = btn.Name
DeleteControl frm.Name, btn.Name
Set btnNew = CreateControl(frm.Name, acCommandButton, acHeader, "", , 1, 1, 500, 500)
btnNew.Name = strName
' Size control.
btnNew.SizeToFit
End Sub
but I do think the earlier suggestions ref have two buttons, amd switch their visible property is a much better way to achieve the desired result.
Regards
Ken Reay
Freelance Developer
kenneth.reay@talk21.com
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.