Requery data

G

Guest

I am using Access 2003. I have a form which uses several queries. The final
query groups records and therefore the form has no editable fields. I have
an edit button which opens another form and allows me to make changes to 2
fields. This 2nd form has a close button which uses the DoCmd.Close code.
What I want to do is preceed this instruction with something like
Form1.Requery so that when Form2 closes Form1 displays the most current data.
Is this possible and if so what code is required.
Thanks.
 
G

Guest

Build a select query for each table you want to compare. Add all fields plus
the following --
Day_Month: Day([YourDateField]) & Right("0" & Month([YourDateField]),2)

Use the Day_Month fields when you join the two queries for comparrison.
 
G

Guest

On closing form2 the data in form1 isn't updated. However if I use the
temporary Requery button I placed on the form the change occurs.
On closing form2 it does go to the 1st record in form1, although this isn't
a problem.
Yes, Form1 is open throughout this process.
PS There is also a response from Karl Dewey but I think he's replying to a
different question because I've read what he's written and it means zippo to
me.?!?
 
G

Guest

Hi, Simon.
On closing form2 the data in form1 isn't updated. However if I use the
temporary Requery button I placed on the form the change occurs.

Then the code for your temporary Requery button is correct, and the code for
your Close button isn't. Place the requery code from the Requery button's
OnClick( ) procedure into the Close button's OnClick( ) procedure. If you
need help, please post your code for both procedures.
PS There is also a response from Karl Dewey but I think he's replying to a
different question because I've read what he's written and it means zippo to
me.?!?

Don't worry. Karl whoopsed. ;-) I'll have to kid him about it next time I
see him at Edwards.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact info.
 
G

Guest

The Requery button that works is on Form1 and is simply On Click ()
Form.Requery.
The problem is that I want to do this automatically when closing Form2. ie
 
6

'69 Camaro

Hi, Simon.
The Requery button that works is on Form1 and is simply On Click ()
Form.Requery.

Okay. Post your code for your Close button on Form2. And Form1 really is
the name of the form you want to requery? You're not just using that name
as an example of the form's name to make things simpler?

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
G

Guest

Yes I am using Form1 and Form2 names to try to keep it simple.
Form1 is called "Funds Client V" and Form2 is called "Funds Price E".
I have just noticed a response to a question posted 4/25/06 "How do refresh
a form?" which I think is very similar to my question. A reply from Douglas
Steele talks about placing code in the edit button on the 1st form
DoCmd.OpenForm "formname", WindowMode:=acDialog
Me!Requery
I have tried this but my form2 is opened using stLinkCriteria and I couldn't
add this to this statement.
Any more thoughts? PS thanks for all your help so far
 
G

Guest

Posted in wrong place.

KARL DEWEY said:
Build a select query for each table you want to compare. Add all fields plus
the following --
Day_Month: Day([YourDateField]) & Right("0" & Month([YourDateField]),2)

Use the Day_Month fields when you join the two queries for comparrison.

Simon said:
I am using Access 2003. I have a form which uses several queries. The final
query groups records and therefore the form has no editable fields. I have
an edit button which opens another form and allows me to make changes to 2
fields. This 2nd form has a close button which uses the DoCmd.Close code.
What I want to do is preceed this instruction with something like
Form1.Requery so that when Form2 closes Form1 displays the most current data.
Is this possible and if so what code is required.
Thanks.
 
G

Guest

Hi, Simon.
DoCmd.OpenForm "formname", WindowMode:=acDialog
Me!Requery
I have tried this but my form2 is opened using stLinkCriteria and I couldn't
add this to this statement.

You also need the WhereCondition parameter, like this:

WhereCondition:=stLinkCriteria

So that you don't have to remember the names of the parameters, it may be
easier to just use commas for the missing optional parameters when calling
the second form from the event in your first form, like this:

stDocName = "Funds Price E"
stLinkCriteria = "ClientID = '" & Me!ClientID & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Me.Requery

Or if you'd rather avoid opening the second form in dialog mode, and just
requery the first form from the second form, try:

Private Sub CloseBtn_Click()

On Error GoTo ErrHandler

Forms("Funds Client V").Requery
DoCmd.Close

Exit Sub

ErrHandler:

MsgBox "Error in CloseBtn_Click( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear

End Sub ' CloseBtn_Click( )

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact info.
 
G

Guest

Brilliant!! I am now going to pour myself a large beer having spent nearly
all day on this. If you we here I'de pour you one too. I used the version
which opens Form2 in dialog mode as I had already tried option 2. However, I
am interested to know why I might "wish to avoid opening the form in dialog
mode" it looks and acts the same as far as I can see?
Thanks again
 
6

'69 Camaro

You're welcome!
However, I
am interested to know why I might "wish to avoid opening the form in
dialog
mode" it looks and acts the same as far as I can see?

If you open the "Funds Price E" form in dialog mode and wish to refer back
to another form to get information, like copying a client's customer number
to paste it into the "Funds Price E" form, you'll find that you must close
the "Funds Price E" form first, because you can't set focus to any other
object when a window is in dialog mode. This can be inconvenient, but most
of the time when a form is opened in dialog mode, you really don't want
users to be playing with any other form or other object in the database than
the one they currently have open. Opening a form in dialog mode helps
control data input, because you have a captive audience, so to speak.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
G

Guest

Thanks again, very well explained.

'69 Camaro said:
You're welcome!


If you open the "Funds Price E" form in dialog mode and wish to refer back
to another form to get information, like copying a client's customer number
to paste it into the "Funds Price E" form, you'll find that you must close
the "Funds Price E" form first, because you can't set focus to any other
object when a window is in dialog mode. This can be inconvenient, but most
of the time when a form is opened in dialog mode, you really don't want
users to be playing with any other form or other object in the database than
the one they currently have open. Opening a form in dialog mode helps
control data input, because you have a captive audience, so to speak.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 

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

Similar Threads


Top