I'm opening a subform in design view from a procedure in another unrelated form and adding a combo box control through vba. Everything works fine until I try to save and close the subform. As soon as the code reaches the line to save it, I get the following error: "Microsoft Access cannot complete this operation. You must stop the code and try again" (run-time error 29068). Consequently, the user must be prompted about whether it should be saved before closing, which I do not want. The whole idea is to do a quick change, then save and close automatically. Does anyone know why the DoCmd.Save acForm, "SubformName" would not be working? Thanks in advance if anyone knows a solution. Here's the pertinent code:
DoCmd.OpenForm "SubformName", acDesign
Dim NewComboBox As Control
Set NewComboBox = CreateControl("SubformName", acComboBox, acDetail, , fname)
Dim p As Property
For Each p In NewComboBox.Properties
If p.name = "Name" Then
p.Value = fname
End If
Next p
'Here's where it stalls, which I've had to comment out:
'DoCmd.Save acForm, "SubformName"
'This results in an unwanted user prompt:
DoCmd.Close acForm, "SubformName
DoCmd.OpenForm "SubformName", acDesign
Dim NewComboBox As Control
Set NewComboBox = CreateControl("SubformName", acComboBox, acDetail, , fname)
Dim p As Property
For Each p In NewComboBox.Properties
If p.name = "Name" Then
p.Value = fname
End If
Next p
'Here's where it stalls, which I've had to comment out:
'DoCmd.Save acForm, "SubformName"
'This results in an unwanted user prompt:
DoCmd.Close acForm, "SubformName