Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
pretoria
Starting Member
6 Posts |
Posted - 2005-07-26 : 12:09:54
|
I've got two tables. 1) Financials 2)CandidatesI've got a form for "Candidates" with a subform "Financials"In the subform I'm trying to create an event procedure in field "Status" 'after change' that will Dlookup a value in the Candidates table (ConsultFee) and divide that value by 4 and place the result in the "Financials" table for field (Amount). This is working, except when I go to another record and change the "status" field prompting the same eventprocedure I will not take the "Amount" value from that record but the first record in the table. I think it must have something to do with my strFilter variable. Any ideas anybody? much appreciated. Private Sub StatusID_FK_AfterUpdate()On Error GoTo Err_StatusID_FK_AfterUpdate Dim strFilter As String ' Evaluate filter before it's passed to DLookup function. strFilter = "FinID = " & Me!FinID 'the primary key in the Financials table (subform) ' Look up product's unit price and assign it to UnitPrice control. Me!Amount = DLookup("ConsultFee", "Candidates", strFilter) / 4 Exit_StatusID_FK_AfterUpdate: Exit SubErr_StatusID_FK_AfterUpdate: MsgBox Err.Description Resume Exit_StatusID_FK_AfterUpdateEnd Sub |
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2005-07-29 : 12:31:01
|
What is the relationship between these two tables? From the way you describe the forms, I would expect that Financials is a child of Candidates. And typically in that setup, the Financials would contain the Primary Key of Candidates within the Financials table as a Foreign Key field. However, your lookup appears to be defined in just the reverse. Are you sure that FinID exists in the Candidates table?Or another way of saying this is, shouldn't your strFilter be based on the Primary Key of the Candidates table, not the Financials table?---------------------------EmeraldCityDomains.com |
 |
|
|
|
|