Subform not showing the correct records

gobyg

Registered User.
Local time
Today, 07:26
Joined
Jul 18, 2013
Messages
20
Table Info:

EmpProfile: EmpID (Primery Key), EmpFirstName, EmpLastName, Emptitle, EmpPhoneNumber

EmpTimes: EmpID (1 to Many relationship with EmpID primery key), Timein, Break, TimeOut, Totalhours

Query Name:
Selects the table from EmpTimes
Calculates the total hours worked for an empid, on a given day. It produces the total hours as "CalcTime"


Form Info:

1st Form Name: MainForm
Text name to enter empID : Txtempid (unbound)
Record Source: EmpProfile


2nd form name: SFTimeSheet
This is a subform within main form
Record Source: QryTime
Child and master fields are linked using : EmpID


Expecting Result:

When enter empid on the MainForm, in txtempid
subform should retrieve all entries for that empid

Getting result:

regardless what empid entered in txtempid, subform shows only the 1st record available in EmpTimes.


Any help is appriciated.
 
How is the employee being selected on the main form? When you scroll through the records on the main form does the subform change? It sounds like you have a bound main form and are just changing the empID of the first record instead of navigating to the record.
 
I actually made this work, by changing the txtempid to empid.

Soon after the change subform started to show the right data belongs to the user.

Thank you boblarson anyway
 
You need code in the AfterUpdate event of the unbound control to position the form's recordSource to the desired record. Once the main form is requeried, the subform will automatically sync itself provided the master/child links are correctly set.

I use criteria in my mainform query that refers to the unbound control or controls used for searching.

Select ...
From ...
Where Somefield = Forms!myform!txtSearchSomefield;

Then in the AfterUpdate event of the unbound control I requery the main form.
Me.Requery

When multiple search fields are used, it is better to use a button to force the requery so the user can put data in multiple fields before doing the search.
 

Users who are viewing this thread

Back
Top Bottom