coding forms for data

  • Thread starter Thread starter David
  • Start date Start date
D

David

I have a form for new employee data which is linked to
the employee table. However, I need the data from
several text boxes on the form which contain salary
information to be dumped to a second table. I am having
trouble sending that data to its correct place using
VBA. I've been programming in proprietary languages for
too long and can't seem to get a syntax/method which will
work for me. Any help would be appreciated. I know it
should be easy but...

Table Employee:
ID, Name, Address, Phone, SS#, Start Date.. etc.

Table Salary
ID, RaiseDate, Amount, Interval (hourly/salary)

The form has all fields from Employee and 2 text boxes
for amount and interval (salary). I need to take the
StartDate for Employee and add that with the ID, amount
and interval to give the initial pay in the Salary
table. Currently, I have the form linked to the Employee
Table, but that can be changed.
 
David said:
I have a form for new employee data which is linked to
the employee table. However, I need the data from
several text boxes on the form which contain salary
information to be dumped to a second table. I am having
trouble sending that data to its correct place using
VBA. I've been programming in proprietary languages for
too long and can't seem to get a syntax/method which will
work for me. Any help would be appreciated. I know it
should be easy but...

Table Employee:
ID, Name, Address, Phone, SS#, Start Date.. etc.

Table Salary
ID, RaiseDate, Amount, Interval (hourly/salary)

The form has all fields from Employee and 2 text boxes
for amount and interval (salary). I need to take the
StartDate for Employee and add that with the ID, amount
and interval to give the initial pay in the Salary
table. Currently, I have the form linked to the Employee
Table, but that can be changed.

Hi David,

If I'm understanding what you want correctly, try this:

Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset ("SalaryTableName", dbOpenDynaset)
With rs
.AddNew
.ID = Me.IDFieldName
.RaiseDate = Me.StartDateFieldName
.Amount = Me.AmountFieldName
.Interval = Me.IntervalFieldName
.Update
End With
rs.Close
Set rs = Nothing
Set db = Nothing

HTH
Steve C
 
Back
Top