djsmith2005
Registered User.
- Local time
- Today, 12:17
- Joined
- Sep 6, 2012
- Messages
- 15
Using Access 2010: I have a query with four fields: ORG_NAME, PERS_NAME_LAST, CountOfORG_NAME, and BdMbrCount.
There are a couple hundred companies in the database with 1-7 people associated with each company. I need to number each person so that they have a number, 1-7 in the MemberCount field of my query.
I understand the concept of loops, but am not sure how to make this happen in VBA. I have my query connected to VBA code, thanks to a post, I came across on Access World Forums.
I have experimented with code that I have found on the forum, just to see if I could get something to work and I am getting “Undefined function ‘BdMbrCount’ in expression. I am trying to pass [ORG_NAME],[PERS_NAME_LAST] to my function and assign the value of BdMbrCount to a new field in my query, BdMbrCount.
Is there anyone here who can assist me in figuring this one out?
There are a couple hundred companies in the database with 1-7 people associated with each company. I need to number each person so that they have a number, 1-7 in the MemberCount field of my query.
I understand the concept of loops, but am not sure how to make this happen in VBA. I have my query connected to VBA code, thanks to a post, I came across on Access World Forums.
I have experimented with code that I have found on the forum, just to see if I could get something to work and I am getting “Undefined function ‘BdMbrCount’ in expression. I am trying to pass [ORG_NAME],[PERS_NAME_LAST] to my function and assign the value of BdMbrCount to a new field in my query, BdMbrCount.
Is there anyone here who can assist me in figuring this one out?
Code:
Function BdMbrNumber()
Dim qdf As DAO.QueryDef
Set qdf = CurrentDb.QueryDefs("YourBdMbrsRRecognizedQry")
'Set rst = CurrentDb.OpenRecordset("SELECT [ORG_Name],[PERS_NAME_LAST],[CountofORG_NAME], [BdMbrCount] FROM YourBdMbrsRRecognizedQry")
Dim ORG_NAME As String
Dim PERS_NAME_LAST As String
Dim CountofORG_NAME
Dim BdMbrCount As Double
'qdf.Fields = [ORG_NAME]
' qdf.Fields = [PERS_NAME_LAST]
' qdf.Fields = [CountofORG_NAME]
'qdf.Fields = [BdMbrCount]
'qdf.Execute
Dim i As Integer
i = 1
If rst.BOF Then
rst.MoveFirst
Do While Not rst.EOF
rst.Edit
rst![BdMbrCount] = i
i = i + 1
If i > 12 Then i = 1
rst.MoveNext
Loop
End If
rst.Close
Set rst = Nothing
End Function
Last edited: