Option Group Frame (1 Viewer)

kevsim

Registered User.
Local time
Tomorrow, 05:39
Joined
Aug 10, 2002
Messages
34
I am using Access 2000 and trying to make an option group frame for sorting records. When I use the below code, I receive an error message, “Object does not support this property or method” when the code reaches line .RowSource. I would appreciate some advise as to how fix the problem.
Kevsim

Private Sub Frame266_BeforeUpdate(Cancel As Integer)

Dim SQLText, WClause
SQLText = "SELECT [Product],FROM T_Product WHERE ProdComp = "
Select Case Me![Frame266]
Case 1
WClause = Chr(34) & "Prod" & Chr(34)
Case 2
WClause = Chr(34) & "Comp" & Chr(34)
Case 3
SQLText = "SELECT [Product],FROM T_Product"
WClause = ""
End Select

With Me![Frame266]
.RowSource = SQLText & WClause
.Requery
.BackColor = RGB(255, 255, 255)
End With
End Sub
 

Mile-O

Back once again...
Local time
Today, 20:39
Joined
Dec 10, 2002
Messages
11,316
Quit simply, a frame/oprion group control does not have a RowSource property. So, as you try and assign the SQL to it, it generates an error.
 

kevsim

Registered User.
Local time
Tomorrow, 05:39
Joined
Aug 10, 2002
Messages
34
Mile-O-Phile, Thanks for the info. I realised my first error, as I am attemting to limit the list in Combo2. I used Frame266 in the With Me! statement. I have now placed Combo2 in it's place. My list from Combo2 shows nothing, no matter what button I press. Could you please assist for when I select Button 1 Case 1, it only selects those items from Combo2.
My code was changed to -

Private Sub Frame266_BeforeUpdate(Cancel As Integer)

Dim SQLText, WClause
Select Case Me![Frame266]
Case 1
WClause = Chr(34) & "Prod" & Chr(34)
Case 2
WClause = Chr(34) & "Comp" & Chr(34)
Case 3
SQLText = "SELECT [Product],FROM T_Product"
WClause = ""
End Select

With Me![Combo2]
SQLText = "SELECT [Product],FROM T_Product WHERE ProdComp = "
.RowSource = SQLText & WClause
.Requery
.BackColor = RGB(255, 255, 255)
End With
End Sub










kevsim
 

Mile-O

Back once again...
Local time
Today, 20:39
Joined
Dec 10, 2002
Messages
11,316
"SELECT [Product],FROM T_Product" is wrong.

"SELECT [Product] FROM T_Product " is right.
 

kevsim

Registered User.
Local time
Tomorrow, 05:39
Joined
Aug 10, 2002
Messages
34
I thank you all for assistance provided, my final code is as below and works OK -

Private Sub Frame256_AfterUpdate()
Dim SQLText, WClause
SQLText = "SELECT DISTINCT [ProductID],[Product], [Manufacturer],[ProdComp]FROM T_Product Where ProdComp="
Select Case Me![Frame256]
Case 1
WClause = Chr(34) & "Prod" & Chr(34)
Case 2
WClause = Chr(34) & "Comp" & Chr(34)
Case 3
SQLText = "SELECT [ProductID],[Product],[Manufacturer],[ProdComp]FROM T_Product"
WClause = ""
End Select

With Me![Combo2]
.RowSource = SQLText & WClause
.Requery
.BackColor = RGB(254, 254, 254)
End With
End Sub

The only issue I have left, is when I make the selection of 1 or 2, the records are not sorted in order, how can I achieve this?
I would appreciate any advise.
Kevsim
 

Mile-O

Back once again...
Local time
Today, 20:39
Joined
Dec 10, 2002
Messages
11,316
Create another string with "ORDER BY MyField;" and tack it onto the end of the SQL you build.
 

kevsim

Registered User.
Local time
Tomorrow, 05:39
Joined
Aug 10, 2002
Messages
34
I add to the SQL Statement as shown, I can not receive any listing when I press button 1 or 2, for button 3 the data displays but is still not sorted. I tried with the DISTINCT in and out of the statement. I also tried with the table name in front of product.
Could you please assist further.
kevsim

SQLText = "SELECT DISTINCT [ProductID],[Product], [Manufacturer],[ProdComp]FROM T_Product Where ProdComp=" _
& "Order by Product"
Select Case Me![Frame256]
 

Users who are viewing this thread

Top Bottom