DogLover2006
Technical User
Here is what I did I made a button create a textbox not I want it to bound the box to the query field that matches the string here is my code:
Dim frm As Form, ctlDefault As Control, ctlNew As Control
Dim intLtxt1 As Integer, intLeft, intTop1, intTop2, intNum, intSum, intNewLeft, intName
intLeft = 8760
intTop1 = 1140
intTop2 = 720
intSum = 10440 - 8760
intNum = intLeft + intSum
intLtxt1 = intNum
intNewLeft = intLeft + intSum + intSum
intName = Year(Now()) + 1
strName = intName
DoCmd.OpenForm "Temp_Federal", acDesign
Set frm = Forms!Temp_Federal
frm.RecordSource = "dbs.QueryDefs!qryTmpFed"
'Forms!Temp_Federal.RecordSource = dbs.QueryDefs!qryTmpFed
' Return Control object representing default Text box.
DoCmd.RunMacro "RenameTable"
frm.RecordSource = "dbs.QueryDefs!qryTemp_Federal"
' Form!Temp_Federal.RecordSource = dbs.QueryDefs!qryTemp_Federal
Set ctlDefault = frm.DefaultControl(acTextBox)
' Set some default properties.
With ctlDefault
.FontWeight = 700
.FontSize = 12
.Width = 1440
.Height = 300
.ControlSource = "dbs.QueryDefs!qryTemp_Federal!Field(strName)"
End With
' Create new text box.
Set ctlNew = CreateControl(frm.Name, acTextBox, , , , intLtxt1, intTop1)
' Set control's caption.
ctlNew.Name = intName
Set ctlDefault = frm.DefaultControl(acLabel)
' Set some default properties.
With ctlDefault
.FontWeight = 700
.FontSize = 12
.Width = 1440
.Height = 300
.TextAlign = 2
End With
' Create new lable.
Set ctlNew = CreateControl(frm.Name, acLabel, , , , intLtxt1, intTop2)
' Set control's caption.
ctlNew.Caption = intName
' Restore form.
DoCmd.Restore
DoCmd.RunMacro "saveform"
DoCmd.DeleteObject acTable, "TmpYears"
DoCmd.DeleteObject acQuery, "qryTmpFed"
Dim frm As Form, ctlDefault As Control, ctlNew As Control
Dim intLtxt1 As Integer, intLeft, intTop1, intTop2, intNum, intSum, intNewLeft, intName
intLeft = 8760
intTop1 = 1140
intTop2 = 720
intSum = 10440 - 8760
intNum = intLeft + intSum
intLtxt1 = intNum
intNewLeft = intLeft + intSum + intSum
intName = Year(Now()) + 1
strName = intName
DoCmd.OpenForm "Temp_Federal", acDesign
Set frm = Forms!Temp_Federal
frm.RecordSource = "dbs.QueryDefs!qryTmpFed"
'Forms!Temp_Federal.RecordSource = dbs.QueryDefs!qryTmpFed
' Return Control object representing default Text box.
DoCmd.RunMacro "RenameTable"
frm.RecordSource = "dbs.QueryDefs!qryTemp_Federal"
' Form!Temp_Federal.RecordSource = dbs.QueryDefs!qryTemp_Federal
Set ctlDefault = frm.DefaultControl(acTextBox)
' Set some default properties.
With ctlDefault
.FontWeight = 700
.FontSize = 12
.Width = 1440
.Height = 300
.ControlSource = "dbs.QueryDefs!qryTemp_Federal!Field(strName)"
End With
' Create new text box.
Set ctlNew = CreateControl(frm.Name, acTextBox, , , , intLtxt1, intTop1)
' Set control's caption.
ctlNew.Name = intName
Set ctlDefault = frm.DefaultControl(acLabel)
' Set some default properties.
With ctlDefault
.FontWeight = 700
.FontSize = 12
.Width = 1440
.Height = 300
.TextAlign = 2
End With
' Create new lable.
Set ctlNew = CreateControl(frm.Name, acLabel, , , , intLtxt1, intTop2)
' Set control's caption.
ctlNew.Caption = intName
' Restore form.
DoCmd.Restore
DoCmd.RunMacro "saveform"
DoCmd.DeleteObject acTable, "TmpYears"
DoCmd.DeleteObject acQuery, "qryTmpFed"