By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,688 Members | 1,888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,688 IT Pros & Developers. It's quick & easy.

Cacading Update Combo box not refreshing

daniel aristidou
100+
P: 491
Hi i have used the following code to create cascade updating combo boxes. the code worked but as soon as i change the selection on the first combo the second combobox goes blank and does not refresh:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo18_AfterUpdate()
  2.     With Me!Combo16
  3.         If IsNull(Me!Combo18) Then
  4.             .RowSource = ""
  5.         Else
  6.             .RowSource = "select chapter" & _
  7.                          "From Tblchapters" & _
  8.                          "Where Subject=" & Me!Combo18
  9.         End If
  10.         Call .Requery
  11.     End With
  12. End Sub
(Ps i am using access 2007)
Am i typing in somthing wrong or is extra code needed?
Sep 1 '07 #1
Share this Question
Share on Google+
2 Replies


JConsulting
Expert 100+
P: 603
Hi i have used the following code to create cascade updating combo boxes. the code worked but as soon as i change the selection on the first combo the second combobox goes blank and does not refresh:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo18_AfterUpdate()
  2.     With Me!Combo16
  3.         If IsNull(Me!Combo18) Then
  4.             .RowSource = ""
  5.         Else
  6.             .RowSource = "select chapter" & _
  7.                          "From Tblchapters" & _
  8.                          "Where Subject=" & Me!Combo18
  9.         End If
  10.         Call .Requery
  11.     End With
  12. End Sub
(Ps i am using access 2007)
Am i typing in somthing wrong or is extra code needed?
It worked...but then it didn't work? :o)
you don't need to requery when setting a controls rowsource. It also looked like your rowsource SQL had a spacing issue. Also, if Subject is "text", then you must surround the value with ' ' as shown below.
J

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo18_AfterUpdate()
  2.    With Me!Combo16
  3.         If IsNull(Me!Combo18) Then
  4.             .RowSource = ""
  5.              MsgBox "There are no Chapters for this selection."
  6.         Else
  7.             .RowSource = "select chapter" & _
  8.                          " From Tblchapters" & _
  9.                          " Where Subject='" & Me!Combo18 & "'"
  10.         End If
  11.     End With
  12.  
Sep 1 '07 #2

daniel aristidou
100+
P: 491
thanks
very much :-)
Sep 2 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.