![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi NG I am making a form on the fly - it works fine, but... In the form i have a With statement : With frm .Visible = False .Caption = "Ledige tider" .OnOpen = "Private Sub Form_Open(Cancel As Integer)" & vbCrLf & _ " Const conInchesToTwips = 1440" & vbCrLf & _ " Dim intRight As Integer, intDown As Integer, intWidth As Integer, intHeight As Integer" & vbCrLf & _ " DoCmd.Restore" & vbCrLf & _ " intRight = (3 * conInchesToTwips)" & vbCrLf & _ " intDown = 0" & vbCrLf & _ " intWidth = (5 * conInchesToTwips)" & vbCrLf & _ " intHeight = (5.5 * conInchesToTwips)" & vbCrLf & _ " DoCmd.MoveSize intRight, intDown, intWidth, intHeight" & vbCrLf & _ " End Sub" End With The .OnOpen part do not work... How can i write the code in Open procedure in the With statement, so it works...??? Thx in advance... Bjarne "Every day new surprises" |
#3
| |||
| |||
|
|
I am making a form on the fly - it works fine, but... In the form i have a With statement : With frm .Visible = False .Caption = "Ledige tider" .OnOpen = "Private Sub Form_Open(Cancel As Integer)" & vbCrLf & _ " Const conInchesToTwips = 1440" & vbCrLf & _ " Dim intRight As Integer, intDown As Integer, intWidth As Integer, intHeight As Integer" & vbCrLf & _ " DoCmd.Restore" & vbCrLf & _ " intRight = (3 * conInchesToTwips)" & vbCrLf & _ " intDown = 0" & vbCrLf & _ " intWidth = (5 * conInchesToTwips)" & vbCrLf & _ " intHeight = (5.5 * conInchesToTwips)" & vbCrLf & _ " DoCmd.MoveSize intRight, intDown, intWidth, intHeight" & vbCrLf & _ " End Sub" End With The .OnOpen part do not work... How can i write the code in Open procedure in the With statement, so it works...??? |
#4
| |||
| |||
|
|
bsn wrote: I am making a form on the fly - it works fine, but... In the form i have a With statement : With frm .Visible = False .Caption = "Ledige tider" .OnOpen = "Private Sub Form_Open(Cancel As Integer)" & vbCrLf & _ " Const conInchesToTwips = 1440" & vbCrLf & _ " Dim intRight As Integer, intDown As Integer, intWidth As Integer, intHeight As Integer" & vbCrLf & _ " DoCmd.Restore" & vbCrLf & _ " intRight = (3 * conInchesToTwips)" & vbCrLf & _ " intDown = 0" & vbCrLf & _ " intWidth = (5 * conInchesToTwips)" & vbCrLf & _ " intHeight = (5.5 * conInchesToTwips)" & vbCrLf & _ " DoCmd.MoveSize intRight, intDown, intWidth, intHeight" & vbCrLf & _ " End Sub" End With The .OnOpen part do not work... How can i write the code in Open procedure in the With statement, so it works...??? You have to open the form's module and use the methods of the Module object to insert the code into the module. You would then set the OnOpen PROPERTY to: [Event Procedure] I must say that creating a form object and controls on the fly is a really bad idea except when you are creating a DESIGN TIME wizard to help yourself design forms. It can be a whole truck load of trouble when done in a running application. There is almost never a valid reason to not use a prebuilt form with precreated controls and set their properties as needed when the form is opened. |
#5
| |||
| |||
|
|
"Marshall Barton" <marshbarton (AT) wowway (DOT) com> skrev i en meddelelse news:5joao610u2q73ihl7r913aig654cenb4ju (AT) 4ax (DOT) com... bsn wrote: I am making a form on the fly - it works fine, but... In the form i have a With statement : With frm .Visible = False .Caption = "Ledige tider" .OnOpen = "Private Sub Form_Open(Cancel As Integer)" & vbCrLf & _ " Const conInchesToTwips = 1440" & vbCrLf & _ " Dim intRight As Integer, intDown As Integer, intWidth As Integer, intHeight As Integer" & vbCrLf & _ " DoCmd.Restore" & vbCrLf & _ " intRight = (3 * conInchesToTwips)" & vbCrLf & _ " intDown = 0" & vbCrLf & _ " intWidth = (5 * conInchesToTwips)" & vbCrLf & _ " intHeight = (5.5 * conInchesToTwips)" & vbCrLf & _ " DoCmd.MoveSize intRight, intDown, intWidth, intHeight" & vbCrLf & _ " End Sub" End With The .OnOpen part do not work... How can i write the code in Open procedure in the With statement, so it works...??? You have to open the form's module and use the methods of the Module object to insert the code into the module. You would then set the OnOpen PROPERTY to: [Event Procedure] I must say that creating a form object and controls on the fly is a really bad idea except when you are creating a DESIGN TIME wizard to help yourself design forms. It can be a whole truck load of trouble when done in a running application. There is almost never a valid reason to not use a prebuilt form with precreated controls and set their properties as needed when the form is opened. The forms Source is a crosstabquery... Then if there comes a colown more, it dont appear in the form...:-( Maybee u know a better way...??? |
#6
| |||
| |||
|
|
"Marshall Barton" <marshbarton (AT) wowway (DOT) com> skrev i en meddelelse news:5joao610u2q73ihl7r913aig654cenb4ju (AT) 4ax (DOT) com... bsn wrote: I am making a form on the fly - it works fine, but... In the form i have a With statement : With frm .Visible = False .Caption = "Ledige tider" .OnOpen = "Private Sub Form_Open(Cancel As Integer)" & vbCrLf & _ " Const conInchesToTwips = 1440" & vbCrLf & _ " Dim intRight As Integer, intDown As Integer, intWidth As Integer, intHeight As Integer" & vbCrLf & _ " DoCmd.Restore" & vbCrLf & _ " intRight = (3 * conInchesToTwips)" & vbCrLf & _ " intDown = 0" & vbCrLf & _ " intWidth = (5 * conInchesToTwips)" & vbCrLf & _ " intHeight = (5.5 * conInchesToTwips)" & vbCrLf & _ " DoCmd.MoveSize intRight, intDown, intWidth, intHeight" & vbCrLf & _ " End Sub" End With The .OnOpen part do not work... How can i write the code in Open procedure in the With statement, so it works...??? You have to open the form's module and use the methods of the Module object to insert the code into the module. You would then set the OnOpen PROPERTY to: [Event Procedure] I must say that creating a form object and controls on the fly is a really bad idea except when you are creating a DESIGN TIME wizard to help yourself design forms. It can be a whole truck load of trouble when done in a running application. There is almost never a valid reason to not use a prebuilt form with precreated controls and set their properties as needed when the form is opened. The forms Source is a crosstabquery... Then if there comes a colown more, it dont appear in the form...:-( Maybee u know a better way...??? Bjarne |
#7
| |||
| |||
|
|
What I would do is add an ample number of controls to the form at design time, then at run time, set each control's source to the correct column (or to nothing) and make it visible (or not). Seems much simpler to me than creating a form at runtime. Especially for maintenance down the road when client wants more features added to the form. I have done similar with reports based on crosstab data and it works well. |
#8
| |||
| |||
|
|
What I would do is add an ample number of controls to the form at design time, then at run time, set each control's source to the correct column (or to nothing) and make it visible (or not). Seems much simpler to me than creating a form at runtime. Especially for maintenance down the road when client wants more features added to the form. I have done similar with reports based on crosstab data and it works well. -- AG Email: npATadhdataDOTcom "bsn" <bsnSNABELAoncableDOTdk> wrote in message news:4d85a2a5$0$56785$edfadb0f (AT) dtext02 (DOT) news.tele.dk... "Marshall Barton" <marshbarton (AT) wowway (DOT) com> skrev i en meddelelse news:5joao610u2q73ihl7r913aig654cenb4ju (AT) 4ax (DOT) com... bsn wrote: I am making a form on the fly - it works fine, but... In the form i have a With statement : With frm .Visible = False .Caption = "Ledige tider" .OnOpen = "Private Sub Form_Open(Cancel As Integer)" & vbCrLf & _ " Const conInchesToTwips = 1440" & vbCrLf & _ " Dim intRight As Integer, intDown As Integer, intWidth As Integer, intHeight As Integer" & vbCrLf & _ " DoCmd.Restore" & vbCrLf & _ " intRight = (3 * conInchesToTwips)" & vbCrLf & _ " intDown = 0" & vbCrLf & _ " intWidth = (5 * conInchesToTwips)" & vbCrLf & _ " intHeight = (5.5 * conInchesToTwips)" & vbCrLf & _ " DoCmd.MoveSize intRight, intDown, intWidth, intHeight" & vbCrLf & _ " End Sub" End With The .OnOpen part do not work... How can i write the code in Open procedure in the With statement, so it works...??? You have to open the form's module and use the methods of the Module object to insert the code into the module. You would then set the OnOpen PROPERTY to: [Event Procedure] I must say that creating a form object and controls on the fly is a really bad idea except when you are creating a DESIGN TIME wizard to help yourself design forms. It can be a whole truck load of trouble when done in a running application. There is almost never a valid reason to not use a prebuilt form with precreated controls and set their properties as needed when the form is opened. The forms Source is a crosstabquery... Then if there comes a colown more, it dont appear in the form...:-( Maybee u know a better way...??? Bjarne |
#9
| |||
| |||
|
|
On 20/03/2011 12:38:00, "agiamb" wrote: What I would do is add an ample number of controls to the form at design time, then at run time, set each control's source to the correct column (or to nothing) and make it visible (or not). Seems much simpler to me than creating a form at runtime. Especially for maintenance down the road when client wants more features added to the form. I have done similar with reports based on crosstab data and it works well. Equally done it with reports, and you can set the position and size of the controls to best fill the form depending on the number of controls that are visible. Phil |
#10
| |||
| |||
|
|
"Marshall Barton" <marshbarton (AT) wowway (DOT) com> skrev bsn wrote: I am making a form on the fly - it works fine, but... In the form i have a With statement : With frm .Visible = False .Caption = "Ledige tider" .OnOpen = "Private Sub Form_Open(Cancel As Integer)" & vbCrLf & _ " Const conInchesToTwips = 1440" & vbCrLf & _ " Dim intRight As Integer, intDown As Integer, intWidth As Integer, intHeight As Integer" & vbCrLf & _ " DoCmd.Restore" & vbCrLf & _ " intRight = (3 * conInchesToTwips)" & vbCrLf & _ " intDown = 0" & vbCrLf & _ " intWidth = (5 * conInchesToTwips)" & vbCrLf & _ " intHeight = (5.5 * conInchesToTwips)" & vbCrLf & _ " DoCmd.MoveSize intRight, intDown, intWidth, intHeight" & vbCrLf & _ " End Sub" End With The .OnOpen part do not work... How can i write the code in Open procedure in the With statement, so it works...??? You have to open the form's module and use the methods of the Module object to insert the code into the module. You would then set the OnOpen PROPERTY to: [Event Procedure] I must say that creating a form object and controls on the fly is a really bad idea except when you are creating a DESIGN TIME wizard to help yourself design forms. It can be a whole truck load of trouble when done in a running application. There is almost never a valid reason to not use a prebuilt form with precreated controls and set their properties as needed when the form is opened. The forms Source is a crosstabquery... Then if there comes a colown more, it dont appear in the form...:-( Maybee u know a better way...??? |
![]() |
| Thread Tools | |
| Display Modes | |
| |