View Single Post
  #3 (permalink)  
Old January 7th, 2004, 05:39 PM
mtrtxs mtrtxs is offline
Registered User
Join Date: Jan 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

Hello Fishypew and all,


I see I had a typo - missing space in:
setBtnTest = CreateControlblahblahblah

It should have been:
set BtnTest = CreateControlblahblahblah

I'm now at code below...command button working (yay!) but with a macro (mega-boo!!!). I haven't cracked the problem of how to attach code to my command button.

Can you help me plug some code into the form module, or show me how to get the command button to avail itself of code elsewhere?

Out, out accursed macros!

Thanks in advance!!!!!

Private Sub NewControls()

Dim frm As Form
Dim ctlLabel As Control
Dim ctlText As Control
Dim BtnTest As Control

Dim intDataX As Integer
Dim intDataY As Integer
Dim intDataZ As Integer
Dim intLabelX As Integer
Dim intLabelY As Integer
Dim intLabelZ As Integer

Set frm = CreateForm ''''' Create new form

frm.RecordSource = "TblOrders" ' with Orders table as record source

' top, left, width, height - position and size new controls

intDataX = 2000
intDataY = 100
intDataZ = 3000 ' width of textbox is set here - third size argument

' Create unbound default-size text box in detail section.
Set ctlText = CreateControl(frm.Name, acTextBox, , "", "shipname", intDataX, intDataY, intDataZ)
With ctlText

End With

intLabelX = 100
intLabelY = 100
intLabelZ = 1 ' hmmm...width of label seems to be dependent on text within

' Create child label control for text box.
Set ctlLabel = CreateControl(frm.Name, acLabel, , ctlText.Name, "Shipping Name", intLabelX, intLabelY, intLabelZ)

b = ctlLabel.Width

a = frm.Name

With frm
    .DividingLines = False
    .ScrollBars = False
    .RecordSelectors = False
    .AutoResize = True
    .AutoCenter = True
    .BorderStyle = 3
    .Caption = "test"
    .Modal = True
    .ControlBox = False
End With

Set BtnTest = CreateControl(frm.Name, acCommandButton, , , "", 400, 800, 600, 600)

BtnTest.OnClick = "mcrSlam.slamDunk"
' Works, but uggh - it's a macro!

BtnTest.Caption = "&Close"
BtnTest.Cancel = True

DoCmd.OpenForm a, acNormal
DoCmd.MoveSize , , 5555, 5555

End Sub
Reply With Quote