Les Isaacs
Registered User.
- Local time
- Today, 21:38
- Joined
- May 6, 2008
- Messages
- 186
Hi All
I have a table [staffs] with a string fields [staff_name] and [practice] and another field [bank ref order] (integer). I need a function that will assign values to [bank ref order] according to thre alphabetical order of [staff_name] - so
[staff_name] of Andrew Smith gets a [bank ref order] value of 10
[staff_name] of Brian Jones gets a [bank ref order] value of 20
[staff_name] of Charles Brown gets a [bank ref order] value of 30
etc.
So far I have:
... which I think is on the right lines, but obviously my syntax is out!
Hope someone can help.
Many thanks in advance
Les
I have a table [staffs] with a string fields [staff_name] and [practice] and another field [bank ref order] (integer). I need a function that will assign values to [bank ref order] according to thre alphabetical order of [staff_name] - so
[staff_name] of Andrew Smith gets a [bank ref order] value of 10
[staff_name] of Brian Jones gets a [bank ref order] value of 20
[staff_name] of Charles Brown gets a [bank ref order] value of 30
etc.
So far I have:
Code:
Dim rsEmployees As DAO.Recordset
Dim ThisEmployee as String
Dim order as Integer
order = 10
Set rsEmployees = CurrentDb.OpenRecordset("SELECT staffs.practice, staffs.staff_name, staffs.[bank ref order]" & _
" from staffs" & _
" WHERE staffs.practice= """ & practicename & """ " & _
" ORDER BY staffs.staff_name;")
rsEmployees.MoveFirst
While Not rsEmployees.EOF
ThisEmployee = rsEmployees![staff_name]
With ThisEmployee
rsEmployees![bank ref order] = order
order = order + 10
Next
... which I think is on the right lines, but obviously my syntax is out!
Hope someone can help.
Many thanks in advance
Les