Setting RecordSource of a Subform based on text fields on main form.

S

Satadru Sengupta

Friends,
I have a problem on unbound forms.

On the main form I have two vital fields in the form of text boxes.
1. Division.
2. Employee ID.

I have a table which stores alongwith the Division and Employee ID, the days
worked and wages earned every week for 52 weeks in a year.

Based on entries made in the Division and Employee ID text boxes on the main
form, I want to display to the user all the entries absolutely related to
that particular employee of the respective division.
For this purpose, I have made a subform named as "subdetailform" [my main
form is named as just "mainform"], which is displayed on the main form of
course.

I have tried out the following code on the "On Lost Focus" property of the
Employee ID text box on the main form which, unfortunately, does not work to
anyone' satisfaction:

Me![subdetailform].Form.RecordSource = "SELECT tblRawData1.Type,
tblRawData1.Slno, tblRawData1.Name, tblRawData1.Days, tblRawData1.Amount
FROM tblRawData1 WHERE tblRawData1.Type = txtdivision.value AND
tblRawData1.Slno = txtempid.value ORDER BY tblRawData1.Record DESC;"

tblRawData1 => the table which stores the entries.
Type => the field in the table which actually corresponds to the division
text box on the main form.
Slno => the field in the table which corresponds to the Employee ID text box
on the main form.

Your help and assistance is solicited and is precious to me.
Sincerely yours,
Satadru.
 
S

Satadru Sengupta

Friends,
Thank you for your patience. I have, however, managed to solve the issue all
on my own. I am posting the solution for all to view and for further
reference, if required.

Forms![mainform]![subdetailform].Form.RecordSource = "SELECT
tblRawData1.Type, tblRawData1.Slno, tblRawData1.Name, tblRawData1.Days,
tbllRawData1.Amount FROM tblRawData1 WHERE tblRawData1.Type =
txtdivision.value AND tblRawData1.Slno = txtempid.value ORDER BY
tblRawData1.Record DESC;"

Your help and assistance is solicited and is precious to me.
Sincerely yours,
Satadru.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top