Unbound Recordsource throught Code

C

Chris

I have a form that I set the Recordsource to equal a query that I prepared
earlier. Then I bind the controls to the form.

I would like to code the section that will unbind the controls and unbind
the form i.e. make the form unbound.

I can set the forms controls to unbound but I can't make the form unbound
without getting the message;

"Index or Primary key cannot contain a null value"

Any idea's?
 
B

Barry Gilbert

How are you unbinding the form and controls? This should work:
Dim ctl As Control
On Error Resume Next
For Each ctl In Me.Controls
ctl.ControlSource = ""
Next
On Error GoTo 0
Me.RecordSource = ""

Barry
 
B

Barry Gilbert

How are you unbinding the form and controls? This should work:
Dim ctl As Control
On Error Resume Next
For Each ctl In Me.Controls
ctl.ControlSource = ""
Next
On Error GoTo 0
Me.RecordSource = ""

Barry
 
C

Chris

I was doing it that way without the loop. The loop and error handling have
cured the problem.

Thanks Barry
 
Top