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
Microsoft AccessVBA

Avatar of undefined
Last Comment
melinhomes
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?
Avatar of mbizup
mbizup
Flag of Kazakhstan image

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of melinhomes
melinhomes

ASKER

Thank you for your help all, it is very much appreciated
Avatar of melinhomes
melinhomes

ASKER

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!
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo