i am trying to add an module to a form when i press a button
here is my code so far
Dim db As DAO.Database
Dim frm As Form
Dim mdl As Module
Dim lngReturn As Long
Dim ctr1 As Control
Dim ctr2 As Control
Dim frmResize As New clsFormResize
Set frmResize = New clsFormResize
Set db = CurrentDb
Set frm = Application.CreateForm
RunCommand acCmdFormHdrFtr
frm.Section(acHeader).BackColor = RGB(84, 246, 225)
frm.Section(acFooter).BackColor = RGB(84, 246, 225)
Set mdl = frm.Module
lngReturn = mdl.CreateEventProc("Resize", ("Form"))
mdl.InsertLines lngReturn + 2, vbTab & "'Place Holder"
With mdl
Set mdl = frm.Module
lngReturn = mdl.CreateEventProc("Load", ("Form"))
mdl.InsertLines lngReturn + 2, vbTab & "frmResize.initme.Form1"
End With
frm.RecordSelectors = False
frm.NavigationButtons = False
frm.Moveable = True
frm.Caption = "Test Form:"
frm.PopUp = True
'Create Control Buttons
Set ctr1 = CreateControl(frm.Name, acCommandButton, acFooter, , "newbutton", 100, 100, 1000, 600)
With ctr1
ctr1.Name = "cmdclose"
.Tag = "MoveY"
Set mdl = frm.Module
lngReturn = mdl.CreateEventProc("Click", ctr1.Name)
mdl.InsertLines lngReturn + 1, vbTab & "DoCmd.close , Form1, acSaveNo"
ctr1.Caption = "&Close:"
End With
Set ctr2 = CreateControl(frm.Name, acCommandButton, acFooter, , "newbutton", 1100, 100, 1000, 600)
With ctr2
ctr2.Name = "cmdhelp"
.Tag = "GrowX0.5 MoveY"
Set mdl = frm.Module
lngReturn = mdl.CreateEventProc("Click", ctr2.Name)
mdl.InsertLines lngReturn + 1, vbTab & "DoCmd.MoveSize Me.Form.WindowLeft * 0.9, Me.Form.WindowTop * 0.9, Me.Form.WindowWidth * 1.1, Me.Form.WindowHeight * 1.1"
ctr2.Caption = "&Help:"
End With
DoCmd.OpenForm "Form1", acNormal
End Sub
please help
thanks andy
here is my code so far
Dim db As DAO.Database
Dim frm As Form
Dim mdl As Module
Dim lngReturn As Long
Dim ctr1 As Control
Dim ctr2 As Control
Dim frmResize As New clsFormResize
Set frmResize = New clsFormResize
Set db = CurrentDb
Set frm = Application.CreateForm
RunCommand acCmdFormHdrFtr
frm.Section(acHeader).BackColor = RGB(84, 246, 225)
frm.Section(acFooter).BackColor = RGB(84, 246, 225)
Set mdl = frm.Module
lngReturn = mdl.CreateEventProc("Resize", ("Form"))
mdl.InsertLines lngReturn + 2, vbTab & "'Place Holder"
With mdl
Set mdl = frm.Module
lngReturn = mdl.CreateEventProc("Load", ("Form"))
mdl.InsertLines lngReturn + 2, vbTab & "frmResize.initme.Form1"
End With
frm.RecordSelectors = False
frm.NavigationButtons = False
frm.Moveable = True
frm.Caption = "Test Form:"
frm.PopUp = True
'Create Control Buttons
Set ctr1 = CreateControl(frm.Name, acCommandButton, acFooter, , "newbutton", 100, 100, 1000, 600)
With ctr1
ctr1.Name = "cmdclose"
.Tag = "MoveY"
Set mdl = frm.Module
lngReturn = mdl.CreateEventProc("Click", ctr1.Name)
mdl.InsertLines lngReturn + 1, vbTab & "DoCmd.close , Form1, acSaveNo"
ctr1.Caption = "&Close:"
End With
Set ctr2 = CreateControl(frm.Name, acCommandButton, acFooter, , "newbutton", 1100, 100, 1000, 600)
With ctr2
ctr2.Name = "cmdhelp"
.Tag = "GrowX0.5 MoveY"
Set mdl = frm.Module
lngReturn = mdl.CreateEventProc("Click", ctr2.Name)
mdl.InsertLines lngReturn + 1, vbTab & "DoCmd.MoveSize Me.Form.WindowLeft * 0.9, Me.Form.WindowTop * 0.9, Me.Form.WindowWidth * 1.1, Me.Form.WindowHeight * 1.1"
ctr2.Caption = "&Help:"
End With
DoCmd.OpenForm "Form1", acNormal
End Sub
please help
thanks andy