Unbound Recordsource throught Code

  • Thread starter Thread starter Chris
  • Start date Start date
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?
 
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
 
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
 
I was doing it that way without the loop. The loop and error handling have
cured the problem.

Thanks Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top