What is it you are trying to do?? Right now, your query says "Show me all of
the fields in the table, but inly show the data is the corresponding radio
button is selected (TRUE).
If you are trying to limit the number of fields displayed, you need to
change the query def to select only the fields you want to see.
So if you have a form named "MyFormName", with the record source a query
named "qryEB_CDB", I would have a button that would change the query def,
then open the form.
To change the fields displayed, you would close the forl, reselect the
option buttons then open the form again by clicking on the button.
Here is the (--untested--) code:
'************ Code Start **********
Private Sub btnTestQuery_Click()
Dim sSQL As String
Dim loqd As QueryDef
sSQL = ""
If [Forms]![FRM_Purchace Master Menu]![option113] = True Then
sSQL = sSQL & " [BUYER] AS [BUYER-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option115] = True Then
sSQL = sSQL & " [BUYPART] AS [BUYPART-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option117] = True Then
sSQL = sSQL & " [COGENG] AS [COGENG-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option119] = True Then
sSQL = sSQL & " [CSA] AS [CSA-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option121] = True Then
sSQL = sSQL & " [DELCDE] AS [DELCDE-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option123] = True Then
sSQL = sSQL & " [DESC] AS [DESC-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option125] = True Then
sSQL = sSQL & " [DWGREV] AS [DWGREV-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option127] = True Then
sSQL = sSQL & " [DWGSPEC] AS [DWGSPEC-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option129] = True Then
sSQL = sSQL & " [ENGCOM] AS [ENGCOM-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option131] = True Then
sSQL = sSQL & " [EXCP] AS [EXCP-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option133] = True Then
sSQL = sSQL & " [INSPLT] AS [INSPLT-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option135] = True Then
sSQL = sSQL & " [INSTAN] AS [INSTAN-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option137] = True Then
sSQL = sSQL & " [ITEM] AS [ITEM-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option139] = True Then
sSQL = sSQL & " [Loc] AS [Loc-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option141] = True Then
sSQL = sSQL & " [LT] AS [LT-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option153] = True Then
sSQL = sSQL & " [METQ] AS [METQ-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option155] = True Then
sSQL = sSQL & " [MFLAG] AS [MFLAG-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option157] = True Then
sSQL = sSQL & " [MKBUY] AS [MKBUY-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option159] = True Then
sSQL = sSQL & " [MLS] AS [MLS-],"
End If
If [Forms]![FRM_Purchace Master Menu]![option161] = True Then
sSQL = sSQL & " [MNDINSP] As [MNDINSP-],"
End If
sSQL = trlm(sSQL)
' Debug.Print sSQL
If Len(sSQL) > 3 Then
sSQL = Left(sSQL, Len(sSQL) - 1)
' -----------Change the query name---------
Set loqd = CurrentDb.QueryDefs("qryEB_CDB")
stSQL = "SELECT" & sSQL
stSQL = stSQL & " FROM [TBL_EB_CDB Flat File];"
loqd.SQL = stSQL
loqd.Close
End If
' -----------Change the form name---------
DoCmd.OpenForm "MyFormName"
End Sub
'************ Code End **********
HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)
Sub Guy said:
This is my basic query. But like I said, I did not want to see items I did
not select.
SELECT IIf([forms]![FRM_Purchace Master Menu]![option113]=-1,[BUYER],"") AS
[BUYER-], IIf([forms]![FRM_Purchace Master Menu]![option115]=-1,[BUYPART],"")
AS [BUYPART-], IIf([forms]![FRM_Purchace Master
Menu]![option117]=-1,[COGENG],"") AS [COGENG-], IIf([forms]![FRM_Purchace
Master Menu]![option119]=-1,[CSA],"") AS [CSA-], IIf([forms]![FRM_Purchace
Master Menu]![option121]=-1,[DELCDE],"") AS [DELCDE-],
IIf([forms]![FRM_Purchace Master Menu]![option123]=-1,[DESC],"") AS [DESC-],
IIf([forms]![FRM_Purchace Master Menu]![option125]=-1,[DWGREV],"") AS
[DWGREV-], IIf([forms]![FRM_Purchace Master
Menu]![option127]=-1,[DWGSPEC],"") AS [DWGSPEC-], IIf([forms]![FRM_Purchace
Master Menu]![option129]=-1,[ENGCOM],"") AS [ENGCOM-],
IIf([forms]![FRM_Purchace Master Menu]![option131]=-1,[EXCP],"") AS [EXCP-],
IIf([forms]![FRM_Purchace Master Menu]![option133]=-1,[INSPLT],"") AS
[INSPLT-], IIf([forms]![FRM_Purchace Master Menu]![option135]=-1,[INSTAN],"")
AS [INSTAN-], IIf([forms]![FRM_Purchace Master
Menu]![option137]=-1,[ITEM],"") AS [ITEM-], IIf([forms]![FRM_Purchace Master
Menu]![option139]=-1,[Loc],"") AS [Loc-], IIf([forms]![FRM_Purchace Master
Menu]![option141]=-1,[LT],"") AS [LT-], IIf([forms]![FRM_Purchace Master
Menu]![option153]=-1,[METQ],"") AS [METQ-], IIf([forms]![FRM_Purchace Master
Menu]![option155]=-1,[MFLAG],"") AS [MFLAG-], IIf([forms]![FRM_Purchace
Master Menu]![option157]=-1,[MKBUY],"") AS [MKBUY-],
IIf([forms]![FRM_Purchace Master Menu]![option159]=-1,[MLS],"") AS [MLS-],
IIf([forms]![FRM_Purchace Master Menu]![option161]=-1,[MNDINSP],"") AS
[MNDINSP-]
FROM [TBL_EB_CDB Flat File];
--
NGNN Submarines (Mark)
Steve Sanford said:
Please post the SQL of the query and the names or the option buttons.
The names of the fields in the table and their data types would also help.
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)
:
Hey, I have a form with 20 individual unbound radio buttons (Options).
What I want to do is allow users to select any one or many of the
option buttons and produce a query or table that will display data relitive
only to the choices they made. The table in question that my current query is
tied to has all 20 elements in it and this does not seem to be the way to go
(Because everthing shows up and the items they do not select just have blank
data). I'm sure there must be some code or a report generator that would
carry out this task.