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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate Table with a certain field

Status
Not open for further replies.

ajhts

Technical User
May 1, 2001
84
0
0
US
I have a data entry form using a lookup query (datasheet view) to where they enter the employee id and it pulls the name and payrate automatically. Then they enter the number of minutes in the appropriate fields. However, it doesn't save the name or payrate into the table. It only displays them on the query/form. How do I get it to store the payrate field for that line of data into the table with the rest of the line. I can't seem to find any options. Please help!

Thanks,
AJ
 
I'm assuming your payrate control is an UNBOUND textbox on your form (Let's say its' name is Payrat). On the OnClick event of your save button or on the AfterUpdate event of your form, you'll have to place some code like:

Private Sub notebox_AfterUpdate()
Dim DB As DAO.Database
Dim RS As DAO.Recordset
Dim strWhere As String

Set DB = CurrentDb()
Set RS = DB.OpenRecordset("YourTableName", dbOpenDynaset)
strWhere = "[EmployeeID] = " & Me![EmployeeID]
RS.FindFirst strWhere
If RS.NoMatch Then
MsgBox "No match found"
Else
RS.Update
RS![Payrate] = Me![Payrat]
RS.Update
End If
RS.Close
DB.Close
Set RS = Nothing
Set DB = Nothing
End Sub
 
Payrate is pulling the payrate from a different table called therapisttable.

This is a data entry form to enter minutes and some other info. When they select the employee id, it pulls the employees payrate info into it so they can see what they make for the line that they are working on. I need it to store this along with this line in the data entry table.

The reason for this is if an employee gets a pay raise and we modify the therapist master table, all of the previous data entry will change because of the payrate change. I need it all stored by line items, so that a payraise or paycut wont change history.

Does this make sense to you? I am trying to explain the best I can.

Thanks,
AJ
 
How are ya ajhts . . .

And whats wrong with making the form [blue]Bound![/blue]

Calvin.gif
See Ya! . . . . . .
 
Have you tried doing it as a DLookup? It will look up the info in therapisttable based on the EMPLOYEEID variable you entered.



Dim strFilter As String

strFilter = "EMPLOYEEID = "& Me!EMPLOYEEID

Me!PAYRAT = DLookup("PAYRAT","therapisttable",strFilter)
Me!EMPLOYEEID = DLookup("EMPLOYEENAME","therapisttable",strFilter)

HTH!
 
I apologize for my ignorance, but how do I make the form bound??
 
ajhts . . .

Have a look at the [blue]RecordSource[/blue] property of the form! Put the cursor on the porperty line & hit F1 . . .

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top