Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want the same code to update all records. But How?

Status
Not open for further replies.

cashe

Technical User
May 4, 2002
60
GB
Hello All,

I have the following code under a button in an Access 2000 subform. The code updates the current record in the subform. How do I get the same code to update all records but under a different button. The records are located in tblAssigned and there is about 800 recs.

The code is:

If Forms![frmContractor]![ABB Emloyee No] < 98000 Then
[SS Rate] = 43#
Else
[SS Rate] = 0#
End If

'This part works out Man Cost
'48 is made up of social security, ABB fee, Holiday Pay
'This only applies to Employed Consultants

If [SS Rate] > 1 Then
Me![Man Cost] = [Hourly Rate] / &quot;100&quot; * 46.75 + [Hourly Rate]
Else
Me![Man Cost] = [Hourly Rate]
End If

Me![Customer Total] = [Man Cost] + [Department] + [IT] + [Office Rent] + [ADMIN] + [Sale] + [Misc]
Me![Fee per Hour] = [Customer Total] - [Man Cost]
Me![Nr Days] = [Demobilised Date] - [Mobilised Date]
Me![Nr Weeks] = [Nr Days] / 7
Me![Nr Working Days] = [Nr Weeks] * 5
Me![Nr Hours] = [Nr Working Days] * [Work Hours Per Day] * [Work Load] / 100
Me![Cost] = [Man Cost] * [Nr Hours]
Me![Total Project Cost] = [Nr Hours] * [Customer Total]
Me![Gross Department Fees] = [Total Project Cost] - [Cost]

Me![Days Left on Project] = [Demobilised Date] - Date
Me![Working Days Left on Project] = [Days Left on Project] / 7 * 5
Me![Working Hours Left on Project] = [Working Days Left on Project] * [Work Hours Per Day]
Me![Days Completed] = [Nr Working Days] - [Working Days Left on Project]
Me![Dep Fees to Date] = [Fee per Hour] * [Work Hours Per Day] * [Days Completed]
Me![Dep Fees Remaining] = [Gross Department Fees] - [Dep Fees to Date]

DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

If [Days Left on Project] < 0 Then
[Days Left on Project] = 0
End If

If [Working Days Left on Project] < 0 Then
[Working Days Left on Project] = 0
End If

If [Working Hours Left on Project] < 0 Then
[Working Hours Left on Project] = 0
End If

If Date >= [Demobilised Date] Then
[Dep Fees to Date] = [Gross Department Fees]
End If

If Date >= [Demobilised Date] Then
[Dep Fees Remaining] = 0
End If

If Date >= [Demobilised Date] Then
[Days Completed] = [Nr Working Days]
End If

If [Dep Fees Remaining] < 0 Then
[Dep Fees Remaining] = 0
End If


I don't want to use an update query and I don't think an update query would cope with the IF statements, or would it?

Hope someone can shed some light.

Cashe
 
I am not an access person, but something like :
'---------------------------------------------------------
Set dbs = DBEngine(0).OpenDatabase _(&quot;C:\temp\MyDatabase.mdb&quot;)
Set MyList = _
dbs.OpenRecordset(&quot;MyTableName&quot;, dbOpenTable)
'- main loop
Do Until MyList.EOF
MySubroutineName
Loop
'--------------------------------------------------------
Regards
BrianB
** Let us know if you get something that works !
================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top