By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,107 Members | 1,323 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,107 IT Pros & Developers. It's quick & easy.

Run a procedure on multiple rows

P: n/a
Hello,

I have a password management database in which I can scroll through a
list of employees for a specific location. I have a nifty generate
password procedure that we use to change passwords on a monthly basis.

The Problem:
It takes quite awhile to run the procedure on each employee (over
250)and update all the passwords.

The Solution:
I'm looking to you for a method in which I can automatically run the
generate password procedure for each employee at a specified location
or even all locations (update the whole table). Sounds like a job for
FOR/NEXT but my VB prowess has proved unsuccessful. Any ideas? I
appreciate your help!
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
If you have a function that returns a new password then wouldn't executing
SQL something like

UPDATE tblEmployees SET EmployeePassword = fNewPassword()

do the job for you?
Of if perhaps it's based on their last password

UPDATE tblEmployees SET EmployeePassword = fNewPassword([EmployeePassword])

Otherwise yes - you could go loopy (in the for/next sense of course).

hth
--

---------------------------------------------------------------
"Mr. Bungle" <sl********@hotmail.com> wrote in message
news:ab**************************@posting.google.c om...
Hello,

I have a password management database in which I can scroll through a
list of employees for a specific location. I have a nifty generate
password procedure that we use to change passwords on a monthly basis.

The Problem:
It takes quite awhile to run the procedure on each employee (over
250)and update all the passwords.

The Solution:
I'm looking to you for a method in which I can automatically run the
generate password procedure for each employee at a specified location
or even all locations (update the whole table). Sounds like a job for
FOR/NEXT but my VB prowess has proved unsuccessful. Any ideas? I
appreciate your help!

Nov 13 '05 #2

P: n/a
Alright phew! I figured it out...I counted the number of records for
that location and created a FOR/NEXT that called the generatepassword
procedure for each record:

Private Sub UpdateStation_Click()
Dim NoR As Byte
Dim CurrentStation As String

DoCmd.GoToRecord , "UserCodes", acFirst

CurrentStation = Me![StationName]
NoR = DCount("*", "UserCodes", "[StationName] =""" & CurrentStation &
"""") - 1

GeneratePassword_Click ' Update the
current record
Me!Password = Me!RandomPassword
Me!DateUpdated = Now()

For x = 1 To NoR
DoCmd.GoToRecord , "UserCodes", acNext 'Cycle Through
each record
GeneratePassword_Click 'and update the
passwords.
Me!Password = Me!RandomPassword
Me!DateUpdated = Now()
Next
DoCmd.GoToRecord , "UserCodes", acFirst 'Go Back To
Initial Record
End Sub
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.