Solved

Requery combobox in datasheet view

Posted on 2000-03-23
5
1,563 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

821 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