Subform refresh help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Either Access 2000 is unreasonably difficult, or I am a moron, but I need
some help. I have an unbound form that has a subform on it. On the unbound
form I have two text boxes where I enter a start date and an end date. Those
boxes are the controls for a query that displays all records in the sepcified
date range. The subform in turn is based on that query. I cannot get the
subform to populate to save my life. If I close and reopen the form, the
subform will populate. I would like to put an event procedure on the
afterupdate for the end date range. Does anyone know what this code would
be? Here is what I am using and where it fails:

Private Sub Command7_Click()

On Error GoTo err_Command7_Click <----- Invalid label
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Exit_Command7_click:


End Sub
 
There are two commands that you should be aware of

Me.Refresh
DoCmd.Requery

Select design mode of the unbound subform and select the form properties. In
the on got focus event of the properties

click in that row and select code builder from the popup option


Enter code

Private Sub Form_GotFocus()

DoCmd.Requery

End Sub

Try that, the form records should now be refreshed on opening

HTH Mike B, please let me know.


--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all,
you have shouted at and blamed the innocent,
and asked everyone you know,

READ THE INSTRUCTION MANUAL.
 
Thanks for the help Mike, but that did not work. All that I want to happen
is for the user to enter the date range. And have the query run with the new
dates. The new query results should then be displayed in the subform. All
automated, maybe with the click of a command button. I did a little work
with Me.Refresh and access tells me it is not defined. I am beginning to
think my version of access is corrupt and that I should throw my computer off
the top of the building and start happy hour early. Your thoughts?
 
Ok, I am sorry I mis-understood your request. I think I know what you want
now and I will post tomorrow, (Sorry only just got in from Dinner Evening)

ATB Mike B
--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all,
you have shouted at and blamed the innocent,
and asked everyone you know,

READ THE INSTRUCTION MANUAL.
 
Ok so what I think you require.

A form with two unbound controls one for the first date, the second for the
final date for records to be selected.

There are a couple of ways of doing what you want.

1. the easiest way, base the form directly on a query In the criteria row
for the query type, Between [Enter the first Date] And [Enter the second]
date.

This will pop up a little form each time the form is opened which will
prompt first date and secnod date.

2. the more complicated method which follows your requirements is as follows:

(The form which contains date data is based on a query, this is important)

I made a simple sub form with only 3 fields for trials

I also made a master form for the two unbound text boxes

On the Master form I dragged the sub form on as normal practice (No child
links or anything because the two controls on the mater form are unbound)

In the properties of the second unbound text box I entered the following
code in the on lost focus event of the control.

Private Sub Text2_LostFocus()
Me.Refresh
End Sub

In the criteria row for the subform I typed

Between [Forms]![Form1]![Text0] And [Forms]![Form1]![Text2]

My Form is called Form1
My TextBoxes are called Text0 and Text2

Replace these names with your form and textbox names

This works I have tried it so if you follow this method you should be able
to get your subform to refresh with the relevant data.

You can also use the build function in the criteria row of the query to
locate the form and text boxes.

You may need a DoCmd.Requery in the on got focus event of the sub form But I
didn't find it necessary.

I really hope this helps, should you have any more problems, please let me
know. You can always send your DB and I'll try to set it up if you like.

E Mail as name @Hotmail.com

MikeJohnB
--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all,
you have shouted at and blamed the innocent,
and asked everyone you know,

READ THE INSTRUCTION MANUAL.
 
Sorry, tired, I have the following amendments

Ok so what I think you require.

A form with two unbound controls one for the first date, the second for the
final date for records to be selected (Add) ***in a sub form on your main
form***

There are a couple of ways of doing what you want.

1. the easiest way, base the form directly on a query In the criteria row
for the query type, Between [Enter the first Date] And [Enter the second]
date.

This will pop up a little form each time the form is opened which will
prompt first date and secnod date.

2. the more complicated method which follows your requirements is as follows:

(The form which contains date data is based on a query, this is important)

I made a simple sub form with only 3 fields for trials

I also made a master form for the two unbound text boxes

On the Master form I dragged the sub form on as normal practice (No child
links or anything because the two controls on the mater form are unbound)

In the properties of the second unbound text box I entered the following
code in the on lost focus event of the control. (Add) ***This resets the
Query of the SubForm***

Private Sub Text2_LostFocus()
Me.Refresh
End Sub

In the criteria row (Add) ***of the underlying query for the*** subform I
typed

Between [Forms]![Form1]![Text0] And [Forms]![Form1]![Text2]

My Form is called Form1
My TextBoxes are called Text0 and Text2

Replace these names with your form and textbox names

This works I have tried it so if you follow this method you should be able
to get your subform to refresh with the relevant data.

You can also use the build function in the criteria row of the query to
locate the form and text boxes.

You may need a DoCmd.Requery in the on got focus event of the sub form But I
didn't find it necessary.

I really hope this helps, should you have any more problems, please let me
know. You can always send your DB and I'll try to set it up if you like.

E Mail as name @Hotmail.com

--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all,
you have shouted at and blamed the innocent,
and asked everyone you know,

READ THE INSTRUCTION MANUAL.


MikeJohnB said:
Ok so what I think you require.

A form with two unbound controls one for the first date, the second for the
final date for records to be selected.

There are a couple of ways of doing what you want.

1. the easiest way, base the form directly on a query In the criteria row
for the query type, Between [Enter the first Date] And [Enter the second]
date.

This will pop up a little form each time the form is opened which will
prompt first date and secnod date.

2. the more complicated method which follows your requirements is as follows:

(The form which contains date data is based on a query, this is important)

I made a simple sub form with only 3 fields for trials

I also made a master form for the two unbound text boxes

On the Master form I dragged the sub form on as normal practice (No child
links or anything because the two controls on the mater form are unbound)

In the properties of the second unbound text box I entered the following
code in the on lost focus event of the control.

Private Sub Text2_LostFocus()
Me.Refresh
End Sub

In the criteria row for the subform I typed

Between [Forms]![Form1]![Text0] And [Forms]![Form1]![Text2]

My Form is called Form1
My TextBoxes are called Text0 and Text2

Replace these names with your form and textbox names

This works I have tried it so if you follow this method you should be able
to get your subform to refresh with the relevant data.

You can also use the build function in the criteria row of the query to
locate the form and text boxes.

You may need a DoCmd.Requery in the on got focus event of the sub form But I
didn't find it necessary.

I really hope this helps, should you have any more problems, please let me
know. You can always send your DB and I'll try to set it up if you like.

E Mail as name @Hotmail.com

MikeJohnB
--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all,
you have shouted at and blamed the innocent,
and asked everyone you know,

READ THE INSTRUCTION MANUAL.


PerplexedinKY said:
Thanks for the help Mike, but that did not work. All that I want to happen
is for the user to enter the date range. And have the query run with the new
dates. The new query results should then be displayed in the subform. All
automated, maybe with the click of a command button. I did a little work
with Me.Refresh and access tells me it is not defined. I am beginning to
think my version of access is corrupt and that I should throw my computer off
the top of the building and start happy hour early. Your thoughts?
 
I'm going to stop doing this after a night on the tiles, too many mistakes.

I forgot to mention that the criterian row of the query relates to the date
field which you want to return the records on. So lets say its something
simple like Date, then the critria row of the query for Date will contain the
statement.

Between [Forms]![Form1]![Text0] And [Forms]![Form1]![Text2]

Sorry again

MikeJohnB
--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all,
you have shouted at and blamed the innocent,
and asked everyone you know,

READ THE INSTRUCTION MANUAL.


MikeJohnB said:
Sorry, tired, I have the following amendments

Ok so what I think you require.

A form with two unbound controls one for the first date, the second for the
final date for records to be selected (Add) ***in a sub form on your main
form***

There are a couple of ways of doing what you want.

1. the easiest way, base the form directly on a query In the criteria row
for the query type, Between [Enter the first Date] And [Enter the second]
date.

This will pop up a little form each time the form is opened which will
prompt first date and secnod date.

2. the more complicated method which follows your requirements is as follows:

(The form which contains date data is based on a query, this is important)

I made a simple sub form with only 3 fields for trials

I also made a master form for the two unbound text boxes

On the Master form I dragged the sub form on as normal practice (No child
links or anything because the two controls on the mater form are unbound)

In the properties of the second unbound text box I entered the following
code in the on lost focus event of the control. (Add) ***This resets the
Query of the SubForm***

Private Sub Text2_LostFocus()
Me.Refresh
End Sub

In the criteria row (Add) ***of the underlying query for the*** subform I
typed

Between [Forms]![Form1]![Text0] And [Forms]![Form1]![Text2]

My Form is called Form1
My TextBoxes are called Text0 and Text2

Replace these names with your form and textbox names

This works I have tried it so if you follow this method you should be able
to get your subform to refresh with the relevant data.

You can also use the build function in the criteria row of the query to
locate the form and text boxes.

You may need a DoCmd.Requery in the on got focus event of the sub form But I
didn't find it necessary.

I really hope this helps, should you have any more problems, please let me
know. You can always send your DB and I'll try to set it up if you like.

E Mail as name @Hotmail.com

--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all,
you have shouted at and blamed the innocent,
and asked everyone you know,

READ THE INSTRUCTION MANUAL.


MikeJohnB said:
Ok so what I think you require.

A form with two unbound controls one for the first date, the second for the
final date for records to be selected.

There are a couple of ways of doing what you want.

1. the easiest way, base the form directly on a query In the criteria row
for the query type, Between [Enter the first Date] And [Enter the second]
date.

This will pop up a little form each time the form is opened which will
prompt first date and secnod date.

2. the more complicated method which follows your requirements is as follows:

(The form which contains date data is based on a query, this is important)

I made a simple sub form with only 3 fields for trials

I also made a master form for the two unbound text boxes

On the Master form I dragged the sub form on as normal practice (No child
links or anything because the two controls on the mater form are unbound)

In the properties of the second unbound text box I entered the following
code in the on lost focus event of the control.

Private Sub Text2_LostFocus()
Me.Refresh
End Sub

In the criteria row for the subform I typed

Between [Forms]![Form1]![Text0] And [Forms]![Form1]![Text2]

My Form is called Form1
My TextBoxes are called Text0 and Text2

Replace these names with your form and textbox names

This works I have tried it so if you follow this method you should be able
to get your subform to refresh with the relevant data.

You can also use the build function in the criteria row of the query to
locate the form and text boxes.

You may need a DoCmd.Requery in the on got focus event of the sub form But I
didn't find it necessary.

I really hope this helps, should you have any more problems, please let me
know. You can always send your DB and I'll try to set it up if you like.

E Mail as name @Hotmail.com

MikeJohnB
--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all,
you have shouted at and blamed the innocent,
and asked everyone you know,

READ THE INSTRUCTION MANUAL.


PerplexedinKY said:
Thanks for the help Mike, but that did not work. All that I want to happen
is for the user to enter the date range. And have the query run with the new
dates. The new query results should then be displayed in the subform. All
automated, maybe with the click of a command button. I did a little work
with Me.Refresh and access tells me it is not defined. I am beginning to
think my version of access is corrupt and that I should throw my computer off
the top of the building and start happy hour early. Your thoughts?

:

There are two commands that you should be aware of

Me.Refresh
DoCmd.Requery

Select design mode of the unbound subform and select the form properties. In
the on got focus event of the properties

click in that row and select code builder from the popup option


Enter code

Private Sub Form_GotFocus()

DoCmd.Requery

End Sub

Try that, the form records should now be refreshed on opening

HTH Mike B, please let me know.


--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all,
you have shouted at and blamed the innocent,
and asked everyone you know,

READ THE INSTRUCTION MANUAL.


:

Either Access 2000 is unreasonably difficult, or I am a moron, but I need
some help. I have an unbound form that has a subform on it. On the unbound
form I have two text boxes where I enter a start date and an end date. Those
boxes are the controls for a query that displays all records in the sepcified
date range. The subform in turn is based on that query. I cannot get the
subform to populate to save my life. If I close and reopen the form, the
subform will populate. I would like to put an event procedure on the
afterupdate for the end date range. Does anyone know what this code would
be? Here is what I am using and where it fails:

Private Sub Command7_Click()

On Error GoTo err_Command7_Click <----- Invalid label
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Exit_Command7_click:


End Sub
 

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

Back
Top