CAN'T CLOSE FORM

  • Thread starter Thread starter Paul Martin
  • Start date Start date
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
 
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
 
Back
Top