Changing of RecordSource Property of a Sub Form

G

Guest

I have One Main Form named "Leave Record" on which there are 3 embaded Sub
Forms developed from 3 different querys. I have a Combo Box "TimeBracket" on
Main Form from which user
can select Different Values of Time Bracket. Basing on that selected value i
want to Changed the RecordSource of all sub forms or to Apply Filters
on all sub forms. I just write the coding for one subform named "Out Pass"
but could not Get thing done. It some time give msg of "Form not Found" or
"the Field
Referred in expression is not found". I used following Code.

The Code is

Forms![Leave Record].[Out Pass].Form!Property!RecordSource = "SELECT *
FROM [Out Pass Query] " & "WHERE [From - Date] > " & " '" &
Me.TimeBraket.Value & "' "

I also Tried to use

Forms![Leave Record].[Out Pass].RecordSource = "SELECT * FROM [Out Pass
Query] " & "WHERE [From - Date] > " & " '" & Me.TimeBraket.Value & "' "

Where
Out Pass Query" is a Valid Query Name
TimeBracket has Numeric Values
Coding is done on "After Update" event of TimeBracket
 
K

kingston via AccessMonster.com

Try this:

Me.[Out Pass].Form.RecordSource = "SELECT... FROM... WHERE...;"

Also, you may need to enclose a date value between # signs instead of single
quotes.

I have One Main Form named "Leave Record" on which there are 3 embaded Sub
Forms developed from 3 different querys. I have a Combo Box "TimeBracket" on
Main Form from which user
can select Different Values of Time Bracket. Basing on that selected value i
want to Changed the RecordSource of all sub forms or to Apply Filters
on all sub forms. I just write the coding for one subform named "Out Pass"
but could not Get thing done. It some time give msg of "Form not Found" or
"the Field
Referred in expression is not found". I used following Code.

The Code is

Forms![Leave Record].[Out Pass].Form!Property!RecordSource = "SELECT *
FROM [Out Pass Query] " & "WHERE [From - Date] > " & " '" &
Me.TimeBraket.Value & "' "

I also Tried to use

Forms![Leave Record].[Out Pass].RecordSource = "SELECT * FROM [Out Pass
Query] " & "WHERE [From - Date] > " & " '" & Me.TimeBraket.Value & "' "

Where
Out Pass Query" is a Valid Query Name
TimeBracket has Numeric Values
Coding is done on "After Update" event of TimeBracket
 
G

Guest

Assuming the code is in the form module of your main form (Leave Record):
Me.[Out Pass].Form.RecordSource = "SELECT *
FROM [Out Pass Query] " & "WHERE [From - Date] > '" &
Me.Parent!TimeBraket & "';"

If [From - Date] is a date/time field, it may need to be:
Me.[Out Pass].Form.RecordSource = "SELECT *
FROM [Out Pass Query] " & "WHERE [From - Date] > #" &
Me.Parent!TimeBraket & "#;"

This would be also assuming [Out Pass] is the name of the Subform control on
your main form, not the name of the form used as the subform.
 

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