Data source for a subform

L

LowFlyer

I've inherited a pretty horrible system which keeps track of customer
data and which is updated from a spreadsheet once a month. The data
from the spreadsheet is imported by manually running a long series of
queries. I thought it would be nice (and easier for non-technical
folk) if I could display a single form with a START button on it and a
set of progress indicators to show how far through things had gone.

All well and good so far.

During the import process a number of manual checks are required -
these are currently displayed as query results, and this seems like a
good way to continue. I'd like to run the query from my main code, and
only display the result form if there's actually anything on it. This
is where I've got so far:

Set rsAddress = CurrentDb.OpenRecordset("3a_CheckAddressDetails")

If Not rsAddress.EOF Then
rsAddress.MoveLast
rsAddress.MoveFirst

If rsAddress.RecordCount > 0 Then
DoCmd.OpenForm "Address Errors", , , , , acDialog
End If
End If

The form opens fine, but it seems a waste of effort and time for it to
run the query again when it opens, so what I've been trying to do is
figure out a way of passing the Recordset I've already got (rsAddress)
to the 'Address Errors' form.

Is this possible, and, if so, any hints as to how would be gratefully
received.

Thanks in advance,
Alastair
 
K

Klatuu

Don't bother to open the recordset where you are doing it now, rather just
open the form and use the Open event to check for records:

Private Sub Form_Open(Cancel As Integer)
If Me.Recordset.RecordCount = 0 Then
MsgBox "No Errors Found"
Cancel = True
End If
End Sub
 

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