Toggle buttons and text box

brian0721

Registered User.
Local time
Today, 07:02
Joined
Dec 5, 2001
Messages
103
Yet another question - toggle buttons and text box help please

Okay, I have 12 toggle boxes one for each month. When I click one, I want to have the 2 text boxes i have (start date and end date) change to what the start and end dates of the month will be. I though I had the code right, but apparently It's wrong and it must be in the wrong spot. Any suggestions? Also, is there a way I can put the months in a drop down box and not have to use the toggle buttons?

Thanks again!!
 
brian0721 said:
Okay, I have 12 toggle boxes one for each month.

Isn't that a bit of overkill? What's wrong with a single combobox with all twelve months included as part of a two column Value List?

Anyway, are you referring to 12 individual toggle buttons or one option group with twelve option?
 
Yeah, I'm not very familiar with combo boxes and stuff. That was my original idea but I could not figure it out. Could you please get me started in the right direction with this?

Thanks a ton!
 
I'd put a combo on the form. Cancel the wizard if that pops up.

Set the combo's Name to: cboMonths
Set the combo's RowSourceType to: Value/List
Set the combo's RowSource to:

1;"January";2;"February";3;"March";4;"April";5;"May";6;"June";7;"July";8;"August";9;"September";10;"October";11;"November";12;"December"

Set the combo's ColumnCount to: 2
Set the combo's BoundColumn to: 1 (probably isn't relevant)
Set the combo's ColumnWidth to: 0cm
Set the combo's LimitToList to: Yes

In the combo's NotInList event, select the code builder and put this line:

Code:
Response = acDataErrContinue

So that the code looks like this:

Code:
Private Sub cboMonths_NotInList(NewData As String, Response As Integer)
    Response = acDataErrContinue
End Sub


In the combo's AfterUpdate event, select the code builder and put these lines:


Code:
Private Sub cboMonths_AfterUpdate()
    If IsNull(Me.cboMonths) Then
        Me.txtStart = Null
        Me.txtEnd = Null
    Else
        Me.txtStart = DateSerial(Year(Date), CLng(Me.cboMonths.Column(0)), 1)
        Me.txtEnd = DateAdd("m", 1, Me.txtStart) - 1
    End If
End Sub

...where txtStart and txtEnd are the names of your two textboxes.
 

Users who are viewing this thread

Back
Top Bottom