PDA

View Full Version : Expression Builder



Yusuf
03-16-2006, 08:03 AM
Hi

I'm new to Access and trying to amend a form's text boxes by the month selected in my combo box

In the cmbMth combo box, I have all the months in Row Source.
Txtbox1 is =[cmbMth] which is fine

Txtbox2 should return Txtbox1 + 1
In other words, if I drop down and select "January" in the cmbMth then Txtbox2 should return "February"

Can this be done in the Control Sourse property's expression builder?

Many thanks
Yusuf

geekgirlau
03-16-2006, 10:10 PM
Private Sub cboMonth_AfterUpdate()
If Me.cboMonth.ListIndex = 11 Then
Me.txtBox2 = Me.cboMonth.ItemData(0)
Else
Me.txtBox2 = Me.cboMonth.ItemData(Me.cboMonth.ListIndex + 1)
End If
End Sub

matthewspatrick
03-17-2006, 07:15 AM
What happens when the user selects December in the combobox?

geekgirlau
03-23-2006, 08:34 PM
That's what the IF statement looks for - if the index number is 11 (i.e. the 12th item, December) it reverts to January.

matthewspatrick
03-23-2006, 08:35 PM
Ah, I see it now :doh: