CAN'T CLOSE FORM

P

Paul Martin

Hi All,
I am using a combo-box to select a contact name, which I then use to
restrict the associated sub-form. It seems to work just fine, except that
when the code has run that restricts the sub-form I can no longer close the
form.

In order to restrict the sub-form, I use the following code:

If Nz(cmbContact.Column(1), "") <> "" Then
strSQL = "SELECT tblCustCalls.* FROM tblCustCalls WHERE
(((tblCustCalls.ContactID)=" _
& Nz(cmbContact.Column(1), 0) & ")) ORDER BY
tblCustCalls.CallDate DESC;"
Else
strSQL = "SELECT tblCustCalls.* FROM tblCustCalls WHERE
(((tblCustCalls.CustID)=" _
& Nz([txtCustID], 0) & ")) ORDER BY tblCustCalls.CallDate
DESC;"
End If

Me.frmCallSub1.Form.RecordSource = strSQL
DoEvents

Can anyone give any suggestions as to what I've done wrong?

Thanks & Regards,

Paul Martin
 
K

Kelvin

Remove DoEvents. This tells Access to wait until the previous line of code
is run and is finsihed. So your code is waiting for the form's recordsource
to no longer be strSQL which it never will be so it just hangs.

Kelvin
 

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

Top