Solved

Requery combobox in datasheet view

Posted on 2000-03-23
5
1,555 Views
Last Modified: 2008-03-17
I have a subform datasheet, with the following columns...

Category  Product  Price

Category and Product columns are both comboboxes.  The rowsource for Products depends on the selection in the catagory combobox, however when i requery the product combobox, it requeries for all records on the datasheet, not for the current record, causing data to 'disappear' from other records.

Is there a way to prevent this from happening?  I tried making the form in continious form view with the same results.  Please help!

Thanks,
Phoat
0
Comment
Question by:Phoat
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
BrianWren earned 50 total points
ID: 2650068
You don't need to requery that box.

In the Afterupdate of the Category combo ptu the following, (presuming the products combo is named 'cboPrd'):


     Me!cboPrd.RowSource = "SELECT * FROM tblProducts WHERE [CategoryID] = " & Me!cboCat


When you set that RowSource, the combo will adapt itself without a requery.

Question?

Brian
0
 
LVL 1

Author Comment

by:Phoat
ID: 2650284
i did that also... but lets say i choose vegetables from the categories column.  The cboPrd column's rowsource will change and i'll be able to pick lets say tomatoes....

but when i goto the next record, and i choose fruit for the categories column, the products column updates its rowsource and the previous record's value disappears.  It changes the rowsource for ALL the records, not just the current one... Im in datasheet view, don't forget.

Phoat
0
 
LVL 1

Author Comment

by:Phoat
ID: 2650310
Ok i got it to work i think....

I'll let you know once i test it a bit

Phoat
0
 
LVL 9

Expert Comment

by:BrianWren
ID: 2650386
Using controls that will change, in datasheet or continuous form views is problematic.

When you change the RowSource, you change the definition of that type of control, for that form.  So they all change.  

I suspect that the underlying data in the table stays the same though...

I would really recommend swtching to single form view, and using the OnCurrent event as well to coordinate these two combos as you move from record to record...

Brian

0
 
LVL 1

Author Comment

by:Phoat
ID: 2651245
i got it work.... Thanks!

The problem was that i was requery-ing the cbo after changing the rowsource, so it would update the display and erase the entries that didn't meet the criteria in the underlying SQL.  It worked after i took out the requery method from the cbo.

Thanks again.

Phoat...
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question