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
melinhomesAsked:
Who is Participating?
 
PatHartmanConnect With a Mentor Commented:
I found an old example.  I'm not sure who built it and I haven't used it.  Possibly Roger Carlson.  If anyone knows, please tell me.

I also uploaded the sample I built years ago which uses the field overlay method for continuous forms.
CascadingComboInSubform2k.zip
FixCascadingCombos130128.zip
1
 
ste5anSenior DeveloperCommented:
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?
0
 
mbizupCommented:
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.
1
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.

 
melinhomesAuthor Commented:
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
0
 
mbizupConnect With a Mentor Commented:
Yes.  Datasheet View does not offer you that kind of flexibility.

Continuous forms give you a lot more control over what is displayed.

(And in Single Form View, this would not be a problem)
1
 
Dale FyeConnect With a Mentor Commented:
Agree with Miriam.

Here is a sample database I prepared for someone with a similar question not too long ago.
20180317-Continuous_and_Datasheet-.accdb
1
 
Dale FyeCommented:
1
 
melinhomesAuthor Commented:
Thank you for your help all, it is very much appreciated
0
 
melinhomesAuthor Commented:
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!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.