Why does this code not work?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have been trying to work out why this code doesn't work and can't. I admit
to being a bit rusty!!n I use Query Defs because I find them easier than
ordinary SQL statements with all their puncutations. Can anyone help, thanks:

strSQL = "SELECT * From qryInvoicePayerIDS;"
Set qdf2 = CurrentDb.CreateQueryDef("", strSQL)
Set rstPayer = qdf2.OpenRecordset

With rstPayer
If Not .EOF Then
.MoveFirst
End If
Do Until .EOF
strInvoicePayer = rstPayer!invoicecontact

'Now get the contact ids the invoice payer is paying for, including himself

strSQL = "PARAMETERS [parContact] Text; "
strSQL = strSQL & "SELECT * From qryInvoicedSubsNoDiscounts WHERE
InvoiceContact = [parContact];"
Set qdf4 = CurrentDb.CreateQueryDef("", strSQL)
qdf4.Parameters("parContact") = strInvoicePayer
Set rstPatientsOnPlan = qdf4.OpenRecordset


rstPatientsOnPlan.MoveFirst
rstPatientsOnPlan.MoveLast
'Count how many are being paid for
intPayees = rstPatientsOnPlan.recordCount
rstPatientsOnPlan.MoveFirst


If Not rstPatientsOnPlan.EOF Then
.MoveFirst
End If
Do Until rstPatientsOnPlan.EOF


strSQL = "SELECT * From
tblMembershipReport;"
Set qdf =
CurrentDb.CreateQueryDef("", strSQL)
Set rstMembershipReport =
qdf.OpenRecordset
rstMembershipReport.AddNew

rstMembershipReport!InvoicePayerID =
strInvoicePayer
rstMembershipReport!PaidForID =
rstPatientsOnPlan!ContactID
rstMembershipReport.Update

rstPatientsOnPlan.MoveNext
Loop



.MoveNext
Loop
End With


Paul
 
Paul, there's no point saying that you code "does not work", unless you
tell us what is happening, from your viewpoint, to make you /say/ it
does not work.

Does it get an error? If so, what is the message & what line of code
does it happen on? Or does the code do nothing? Or does it hang in an
infinite loop? Or produce the wrong result at line #123? Or - what?

Here are some tips to help you ask your questions effectively:
http://tc2.atspace.com/0012-UsingUsenet.htm#PostBody

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
Back
Top