L
L. Lancin
I've written some VB that is supposed to taka a copy of an existing form
called "Simple2Dimension", and thereafter add som more controls to it (se
code below). The copying and adding of controls seems to work, but then the
form won't close (the DoCmd.Close in the attached code). I also have problems
saving/closing the form manually (it simply won't close if I want to save the
changes), and closing it without saving gives the message:
"Microsoft Access Office cannot complete this operation. You must stop the
code and try again."
This indicates that something is running in the background, but what?
Greatful for any guidance.
Sub test()
DoCmd.CopyObject , "TestForm", acForm, "Simple2Dimension"
DoCmd.OpenForm "TestForm", acDesign
Set frm = Screen.ActiveForm
frm.RecordSource = "Employee"
sTableName = "Employee"
frm.Caption = "Form - " & sTableName
iLabelPositionX = 100
iLabelPositionY = 700
iDetailPositionX = 100
iDetailPositionY = 100
Set ctlText = CreateControl(frm.Name, acTextBox, , , "GlobalValue", _
iDetailPositionX, iDetailPositionY, 300)
Set ctlLabel = CreateControl(frm.Name, acLabel, acHeader, , "Global", _
iLabelPositionX, iLabelPositionY, 600)
DoCmd.Close acForm, "TestForm", acSaveYes
End Sub
called "Simple2Dimension", and thereafter add som more controls to it (se
code below). The copying and adding of controls seems to work, but then the
form won't close (the DoCmd.Close in the attached code). I also have problems
saving/closing the form manually (it simply won't close if I want to save the
changes), and closing it without saving gives the message:
"Microsoft Access Office cannot complete this operation. You must stop the
code and try again."
This indicates that something is running in the background, but what?
Greatful for any guidance.
Sub test()
DoCmd.CopyObject , "TestForm", acForm, "Simple2Dimension"
DoCmd.OpenForm "TestForm", acDesign
Set frm = Screen.ActiveForm
frm.RecordSource = "Employee"
sTableName = "Employee"
frm.Caption = "Form - " & sTableName
iLabelPositionX = 100
iLabelPositionY = 700
iDetailPositionX = 100
iDetailPositionY = 100
Set ctlText = CreateControl(frm.Name, acTextBox, , , "GlobalValue", _
iDetailPositionX, iDetailPositionY, 300)
Set ctlLabel = CreateControl(frm.Name, acLabel, acHeader, , "Global", _
iLabelPositionX, iLabelPositionY, 600)
DoCmd.Close acForm, "TestForm", acSaveYes
End Sub