Link to home
Create AccountLog in
Avatar of melinhomes
melinhomes

asked on

VBA refresh current record/control only

I have 2 combo boxes in a sub form (datasheet view).
1.) Category
2.) Question
When a user selects a category, I can get it to filter the question. However, the previous values in the question field disappear. I only want it to filter the current row/record.
Is this possible?
I did attempt doing something like the below, using methods such as re-query and refresh to no avail:
Private Sub Category_AfterUpdate()
Dim recordnum As Integer
recordnum = Me.CurrentRecord
DoCmd.GoToRecord , , acGoTo, (recordnum)
End Sub

Any help would be greatly appreciated.

Kindest regards
Avatar of ste5an
ste5an
Flag of Germany image

You need to set in the On Enter event the filtered data source and On Exit event reset it to show all.

When a user selects a category, I can get it to filter the question. However, the previous values in the question field disappear. I only want it to filter the current row/record.
So the question is, what are you doing exactly?
It sounds like your form is in Continuous Forms View.  Despite *appearing* as though there are separate combo boxes in each record, it is actually only a single control.  When you limit the row source of your combo box, any rows in which the value for that field does not appear in the row source will 'go blank' for that field.

A solution is to overlay a textbox on top of the combo box, bound to the underlying field,  carefully positioned so that the user can sill click the drop down arrow.  With this setup, the textbox will display the stored value regardless of how the drop down list is limited/filtered.

If the underlying field is a numeric ID field, you may need to modify your form's query or use a DLookup in the textbox control source to display the related text.
Avatar of melinhomes
melinhomes

ASKER

Hi mbizup
Its a subform, in datasheet view unfortunately, not continuous forms view. Is the only method to change to form view and overlap?
Thanks
SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Thank you for your help all, it is very much appreciated
Thank you Pat, Dale and Bizup all comments have been very helpful. Thank you Pat for the sample db, it will help me going forward, great work!