“Requery” problem

Martyh

Registered User.
Local time
Today, 03:16
Joined
May 2, 2000
Messages
196
Hi all,

Here is in nutshell what I done and the problem. Could somebody help me out?

1) I Have opened a form called “Car Rental”

2) I Have chosen a control which causes opening of another form “All Markets”

Explaination: “All Markets” is a form which allows you to choose which markets you are going to have within the car rental form.
Eg a complete list of cities in Canada with an “X” (or not) beside them giving you the choice of including (or excluding them from the “Selected Market”.

3) I have also developed a relationship between the tables displayed by “Car Rental” and “All Markets” - a simple one (tblMarket) to many (tblCarRental) companies relationship.

Explaination: The “Selected Market” are used in the “Car Rental” form to calculate several “indices” and is required to display on the screen the market along with the price. It does this in a list control called “lstResult” located on the "CarRental" form.

Here is my code snippet from the close event of the “All Markets” screen.
----------------------------------
Private Sub cmdCloseCM_Click()

' just to make sure that the data has passed from the form to the database
Me.Requery
'then the requery for the main form -- CarRental
Forms!CarRental!lstResult.Requery
'the rest is self explained
DoCmd.Close

End Sub
-----------------------------------

Question: Now for my problem. When I go to close the “All Markets” screen, I can’t get the “Car Rental” form to update.

I thought that this “Requery” should do the trick --- I have attempted all the other “re’s” including repaint and recalc. However nothing seems to work.
H E L P !!!
 
Your ...requery for the main form -- CarRental looks like it is requerying a ListBox rather than the form. Forms!CarRental!lstResult.Requery
 
or you might need to save instead of requery your 'all markets' form (not sure if it's the same effect, maybe it is): docmd.runcommand accmdsaverecord (instead of me.requery)
 
"Requery" still a problem

Thanks for your replys

Rural Guy,
Yes that it my intention: to requery ListBox rather than the form since it has in the list, the “Selected Market” list. I've tried with the list requery (in concert and not) and it doesn't seem to make a bit of difference.

Wazz,
But do I do the requery first and then the save or vice versa ! You might be on to something because when I go out of the come out of the “All Markets” form, and then go back in, the instant that I call the "All Markets" form theings correct themselves on the Main "Car Rental" form.

I am still experimenting ...
 
i have recently experienced this. i ended up requerying the mainform as the is bound to the recordset. if you are on a specific record on the mainform, the the requery will reset this to show the first record so you would need to set the current record in a variable, requery then recall the variable to retrieve your current record!

NS
 
Simple Software Solutions

A bit more VBA but this solution usually works

copy the underlying query sql to the buffer
In the declarations section of the form create a string variable and paste in the SQL to this string

Code:
Private Sub OnLoad()
    StrSQL = "Select * From..."
End sub

Put the following into a private sub

Code:
Private Sub PopulateListBox(Optional MyCriteria As String)
    Me.LstBox.Rowsource = StrSQL & MyCriteria
End Sub

Now on the OnLoad or at any point you want to refresh the list box simply

Code:
Call PopulateListBox(StrCriteria)

CodeMaster::cool:
If you want to apply filters you can pass the criteria to the sub
 

Users who are viewing this thread

Back
Top Bottom