troubleshooting Question

If statements inside record sets

Avatar of SweetingA
SweetingA asked on
Microsoft Access
6 Comments1 Solution372 ViewsLast Modified:
Dear Experts,

How can i alter the code below so that when x = 0 addrecord but when x <> 0 move to next record.

When i have tried adding if staements the recordset stops copying multiple records and only copies onerecord.

PS...Off to bed  now so plenty of time to answer, thanks


Dim rst As DAO.Recordset
    Set rst = CurrentDb.OpenRecordset("SELECT * FROM qry_PDM_Questions WHERE " & Me.Filter)
    Dim rstADD As DAO.Recordset
    Set rstADD = CurrentDb.OpenRecordset("tbl_PDM_Results")

    Dim x As Long

    Do Until rst.EOF
        strSaveCriteria = Me.txtPeriod & Me.txtSite & Me.txtFunction & Me.txtCell & Me.Question
        x = DCount("*", "tbl_PDM_Results", "[SaveCriteria]=" & Chr$(34) & strSaveCriteria & Chr$(34))
            rstADD("Period") = Me.txtPeriod
            rstADD("Site") = Me.txtSite
            rstADD("Function") = rst("Function")
            rstADD("Cell") = Me.txtCell
            rstADD("Question") = rst("Question")
            rstADD("Answer") = rst("Answer")
            rstADD("SaveCriteria") = strSaveCriteria

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros