error 3061

G

Guest

Hi group,

i am trying to execute the code below, but i get the following error (3061)
I think that it is erroring on this line:

Set rsPT = dbCurrent.OpenRecordset("qryQtrRptAge")

please help.

thanks
Lee


Code'''
Public Sub AgeGroups()
On Error GoTo Err_AgeGroups
Dim dbCurrent As DAO.Database
Dim rsPT As DAO.Recordset
Dim varreturn As Variant, lngx As Long
Dim LngCount As Long
Dim HoldDate As String

Set dbCurrent = CurrentDb

Set rsPT = dbCurrent.OpenRecordset("qryQtrRptAge")
DoCmd.SetWarnings False

rsPT.MoveLast
rsPT.MoveFirst
LngCount = rsPT.RecordCount
varreturn = SysCmd(acSysCmdInitMeter, "Converting Age Groups", LngCount)
lngx = 0

Do While rsPT.EOF = False
rsPT.Edit
With rsPT
If rsPT![PatientAge] <= 2 Or rsPT![PatientAge] = 0 Then
rsPT![PatientAgeGroup] = 1
ElseIf (rsPT![PatientAge] >= 3 And rsPT![PatientAge] <= 6) Then
rsPT![PatientAgeGroup] = 2
ElseIf (rsPT![PatientAge] >= 7 And rsPT![PatientAge] <= 12) Then
rsPT![PatientAgeGroup] = 3
ElseIf (rsPT![PatientAge] >= 13 And rsPT![PatientAge] <= 18) Then
rsPT![PatientAgeGroup] = 4
ElseIf (rsPT![PatientAge] >= 19 And rsPT![PatientAge] <= 25) Then
rsPT![PatientAgeGroup] = 5
ElseIf (rsPT![PatientAge] >= 26 And rsPT![PatientAge] <= 35) Then
rsPT![PatientAgeGroup] = 6
ElseIf (rsPT![PatientAge] >= 36 And rsPT![PatientAge] <= 45) Then
rsPT![PatientAgeGroup] = 7
ElseIf (rsPT![PatientAge] >= 45 And rsPT![PatientAge] <= 55) Then
rsPT![PatientAgeGroup] = 8
ElseIf (rsPT![PatientAge] >= 56 And rsPT![PatientAge] <= 65) Then
rsPT![PatientAgeGroup] = 9
ElseIf rsPT![PatientAge] > 66 Then
rsPT![PatientAgeGroup] = 10
Else
rsPT![AgeGroup] = 1
End If
rsPT.Update
End With
lngx = lngx + 1
rsPT.MoveNext
Loop
LngCount = rsPT.RecordCount


Exit_AgeGroups:
varreturn = SysCmd(acSysCmdClearStatus)
DoCmd.SetWarnings True
Exit Sub
Err_AgeGroups:
If Err.Number = 13 Then
Resume Next
' ElseIf Err.Number = 3061 Then
' Resume Next
Else
MsgBox Err & Err.Description
End If

Resume Exit_AgeGroups
End Sub
 
A

Alex Dybenko

Probably something wrong with your query, for example you can not have a
reference to a form in this case, you have to pass value to query parameter
 

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