Group:  Microsoft Access ยป microsoft.public.access.modulesdaovba.ado
Thread: Help with Optionbutton

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Help with Optionbutton
"SF" <ssamnang[ at ]yahoo.com> 03.03.2006 09:00:36
I had a questionaire form that consist of 6 several optionbutions. On my
form, I put these 6 option buttons as below by hope to replace their label
(option1, option2...) to a set of meaningful text from a recordset based on
Qt_QuestionTypeID (1 for Yes/No, 2 for TextBox, 3 for OptionButton)


() Option1
() Option2
() option3
() Option4
() Option5
() option6


I put a code in my form On Current Event as below

Const NUMOPTIONS = 6

Dim I As Integer
Dim s As String
Dim db As DAO.Database
Dim ds As DAO.Recordset

Me.focus.SetFocus

Select Case Me![Qt_QuestionTypeID]

' Multiple
Case 1:
Me![Re_Response_e].Visible = False
Me![Re_Number].Visible = True
Me![Re_YesNo].Visible = False
Me![Re_OLE].Visible = False
Me!Table.Visible = False
' Create a recordset to hold the captions for each question.

Set db = CurrentDb()
Set ds = db.OpenRecordset("Select * from typSurveyQuestionMultiple
where Qm_QuestionID = " & Me![Re_QuestionID] & ";")

If ds.RecordCount > 0 Then
ds.MoveLast
ds.MoveFirst

For I = 1 To NUMOPTIONS
If (Not ds.EOF) Then
If Not IsNull(ds![Qm_OptionText]) Then

Me("Option" & I).Caption = ds![Qm_OptionText]
Me("Option" & I).Visible = True
Me("OptionButton" & I).Visible = True
End If
ds.MoveNext
Else
Me("OptionButton" & I).Visible = False
Me("Option" & I).Visible = False
End If

Next I
ds.Close
End If


Case 2
case 3
case 4
end select

I got 'Item not found in this collection'


Could someone advice?

SF



Re: Help with Optionbutton
"Douglas J Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> 03.03.2006 12:47:14
What line of code is it complaining about?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"SF" <ssamnang[ at ]yahoo.com> wrote in message
news:O3hdBBqPGHA.5908[ at ]TK2MSFTNGP09.phx.gbl...
[Quoted Text]
> I had a questionaire form that consist of 6 several optionbutions. On my
> form, I put these 6 option buttons as below by hope to replace their label
> (option1, option2...) to a set of meaningful text from a recordset based
on
> Qt_QuestionTypeID (1 for Yes/No, 2 for TextBox, 3 for OptionButton)
>
>
> () Option1
> () Option2
> () option3
> () Option4
> () Option5
> () option6
>
>
> I put a code in my form On Current Event as below
>
> Const NUMOPTIONS = 6
>
> Dim I As Integer
> Dim s As String
> Dim db As DAO.Database
> Dim ds As DAO.Recordset
>
> Me.focus.SetFocus
>
> Select Case Me![Qt_QuestionTypeID]
>
> ' Multiple
> Case 1:
> Me![Re_Response_e].Visible = False
> Me![Re_Number].Visible = True
> Me![Re_YesNo].Visible = False
> Me![Re_OLE].Visible = False
> Me!Table.Visible = False
> ' Create a recordset to hold the captions for each question.
>
> Set db = CurrentDb()
> Set ds = db.OpenRecordset("Select * from
typSurveyQuestionMultiple
> where Qm_QuestionID = " & Me![Re_QuestionID] & ";")
>
> If ds.RecordCount > 0 Then
> ds.MoveLast
> ds.MoveFirst
>
> For I = 1 To NUMOPTIONS
> If (Not ds.EOF) Then
> If Not IsNull(ds![Qm_OptionText]) Then
>
> Me("Option" & I).Caption = ds![Qm_OptionText]
> Me("Option" & I).Visible = True
> Me("OptionButton" & I).Visible = True
> End If
> ds.MoveNext
> Else
> Me("OptionButton" & I).Visible = False
> Me("Option" & I).Visible = False
> End If
>
> Next I
> ds.Close
> End If
>
>
> Case 2
> case 3
> case 4
> end select
>
> I got 'Item not found in this collection'
>
>
> Could someone advice?
>
> SF
>
>
>


Re: Help with Optionbutton
"SF" <ssamnang[ at ]yahoo.com> 06.03.2006 01:05:55
I did not the field name corrctly.
If Not IsNull(ds![Qm_OptionText]) Then >> If Not
IsNull(ds![Qm_OptionText_e]) Then

Problem solve now. Thank you

SF
"Douglas J Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> wrote in message
news:eNAeaCsPGHA.3432[ at ]TK2MSFTNGP12.phx.gbl...
[Quoted Text]
> What line of code is it complaining about?
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "SF" <ssamnang[ at ]yahoo.com> wrote in message
> news:O3hdBBqPGHA.5908[ at ]TK2MSFTNGP09.phx.gbl...
>> I had a questionaire form that consist of 6 several optionbutions. On my
>> form, I put these 6 option buttons as below by hope to replace their
>> label
>> (option1, option2...) to a set of meaningful text from a recordset based
> on
>> Qt_QuestionTypeID (1 for Yes/No, 2 for TextBox, 3 for OptionButton)
>>
>>
>> () Option1
>> () Option2
>> () option3
>> () Option4
>> () Option5
>> () option6
>>
>>
>> I put a code in my form On Current Event as below
>>
>> Const NUMOPTIONS = 6
>>
>> Dim I As Integer
>> Dim s As String
>> Dim db As DAO.Database
>> Dim ds As DAO.Recordset
>>
>> Me.focus.SetFocus
>>
>> Select Case Me![Qt_QuestionTypeID]
>>
>> ' Multiple
>> Case 1:
>> Me![Re_Response_e].Visible = False
>> Me![Re_Number].Visible = True
>> Me![Re_YesNo].Visible = False
>> Me![Re_OLE].Visible = False
>> Me!Table.Visible = False
>> ' Create a recordset to hold the captions for each question.
>>
>> Set db = CurrentDb()
>> Set ds = db.OpenRecordset("Select * from
> typSurveyQuestionMultiple
>> where Qm_QuestionID = " & Me![Re_QuestionID] & ";")
>>
>> If ds.RecordCount > 0 Then
>> ds.MoveLast
>> ds.MoveFirst
>>
>> For I = 1 To NUMOPTIONS
>> If (Not ds.EOF) Then
>> If Not IsNull(ds![Qm_OptionText]) Then
>>
>> Me("Option" & I).Caption = ds![Qm_OptionText]
>> Me("Option" & I).Visible = True
>> Me("OptionButton" & I).Visible = True
>> End If
>> ds.MoveNext
>> Else
>> Me("OptionButton" & I).Visible = False
>> Me("Option" & I).Visible = False
>> End If
>>
>> Next I
>> ds.Close
>> End If
>>
>>
>> Case 2
>> case 3
>> case 4
>> end select
>>
>> I got 'Item not found in this collection'
>>
>>
>> Could someone advice?
>>
>> SF
>>
>>
>>
>
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net