Form combobox updating issue (1 Viewer)

tdannay

New member
Local time
Today, 15:38
Joined
Jun 5, 2013
Messages
6
Hello,

I'm skipping an introductory post on the forums for now, and I'll go back to it soon - first I wanted to ask for help! The following is a problem I was unable to find in past posts on this forum, or elsewhere:

I have a form with a combobox and a series of text boxes. Depending on the selection made in the combobox, certain fields are set to become visible/invisible through VBA. The combobox row source pulls its options from a table.

It updates perfectly in all cases except when I select the first option in the combobox. When I select the first option, the form does not update to show/hide the appropriate text boxes, even though the data populating the text boxes updates as it should.

Does anyone know of a possible cause for this?

Many thanks,
Tim
 
Last edited:

jdraw

Super Moderator
Staff member
Local time
Today, 15:38
Joined
Jan 23, 2006
Messages
15,394
Please show the rowsource of the combo. What's special about the first option?
Do you do a Requery after the combo selection to show the "revised" form with the "new values"?
 

tdannay

New member
Local time
Today, 15:38
Joined
Jun 5, 2013
Messages
6
Thanks for your quick response! The row source for the combo looks like this:

SELECT userquery.personKey, userquery.lastName & ", " & userquery.firstName AS Expr1
FROM userquery
ORDER BY userquery.lastName & ", " & userquery.firstName;

There shouldn't be anything special about the first option. There's a table for "userType" and there are three different possible types. The appearance/disappearance of the textboxes is based on the userType of the selected name in the combobox. The first entry of the combobox is the same type as many of the other entries. All of the other entries of its type (and all other types) work perfectly, but that one doesn't.

Also, when I attempted to add a requery to the VBA, it didn't solve the problem. But if I manually click the "Refresh All" button in the Home tab or press Shift+F9 to manually requery, it then updates correctly.
 
Last edited:

missinglinq

AWF VIP
Local time
Today, 15:38
Joined
Jun 20, 2003
Messages
6,423
Whats the exact code behind the Combobox that sets the Visibility of the Controls?

Linq ;0)>
 

tdannay

New member
Local time
Today, 15:38
Joined
Jun 5, 2013
Messages
6
The following code is in the Form's 'On Current' and 'After Update' events, as well as in the combo box's 'After Update' event:

If userType = "Student" Then
Me.title.Visible = False
Me.departments.Visible = False
Me.location.Visible = False
Me.phoneNum.Visible = False
Me.projLevel.Visible = True
Me.careerType.Visible = True
Me.academicPlan.Visible = True
Else
Me.projLevel.Visible = False
Me.careerType.Visible = False
Me.academicPlan.Visible = False
Me.title.Visible = True
Me.departments.Visible = True
Me.location.Visible = True
Me.phoneNum.Visible = True
End If
 

tdannay

New member
Local time
Today, 15:38
Joined
Jun 5, 2013
Messages
6
Please excuse my double-post. I just wanted to share that this explanation seems to be the same thing I'm experiencing: social.msdn.microsoft.com/Forums/en-US/accessdev/thread/58a2a9e0-2623-4488-8434-a21f733c35ed/

If this is indeed a bug and not an error on my part, what workaround would you recommend? What code can I write to replace the AfterUpdate macro created by the combobox wizard, that would trigger the visible/invisible event as described above?

Thanks!
 

John Big Booty

AWF VIP
Local time
Tomorrow, 05:38
Joined
Aug 29, 2005
Messages
8,262
From here;
When you change the text in a text box or in the text box portion of a combo box, the Change event occurs. This event occurs whenever the contents of the control change, but before you move to a different control or record (and thus, before the BeforeUpdate and AfterUpdate events occur). The following sequence of events occurs for each key you press in a text box or in the text box portion of a combo box:
 

tdannay

New member
Local time
Today, 15:38
Joined
Jun 5, 2013
Messages
6
Thanks! That worked perfectly. I knew there had to be a way that I was overlooking.
 

Users who are viewing this thread

Top Bottom