hode/unhide columns in unbound subform in datasheet view

Status
Not open for further replies.

pebbles_bam

New member
Local time
Today, 18:03
Joined
Jul 13, 2012
Messages
4
hello,
please please- i am a beginner and not very familiar with VBA
formname= frm_ETC
subformname=frm_sub
subform source : variable query, always named qry_ETC
this query can have a group by on 4 or 6 or 8 fields
depending on the groupby i only want to see the fields in de query
build by sql
i founded some code, used it as below, but it does not work:

Dim qdf As DAO.QueryDef
Set qdf = CurrentDb.QueryDefs("qry_ETC_High")


--selection in listbox
If list = "Highest Level" Then
qdf.SQL = " SELECT tbl_ETC_Plus.[Primary_role], tbl_ETC_Plus.[Investment_role], tbl_ETC_Plus.[Assignment_Role], tbl_ETC_Plus.[ETC_M],Sum(tbl_ETC_Plus.ETC) AS SumOfETC"
qdf.SQL = qdf.SQL & " FROM tbl_ETC_Plus"
qdf.SQL = qdf.SQL & " GROUP BY tbl_ETC_Plus.[Primary_role], tbl_ETC_Plus.[Investment_role], tbl_ETC_Plus.[Assignment_Role] , tbl_ETC_Plus.[ETC_M] "
Set qdf = Nothing
Me.frm_Sub.Form.Requery
Set qdf = CurrentDb.QueryDefs("qry_ETC_High")
Forms!frm_etc.frm_Sub.Form.RecordSource = "qry_ETC_High"
Me.frm_Sub.Form.Requery

with another selection in the listbox, more variale are in the groupby

subforms always shows all fields- but some then with value=#name
i tried al kind of code on the event: on current and on load of the subform
but nothing works

how to resolve this
many thanks for your attention
 
Status
Not open for further replies.

Users who are viewing this thread

Back
Top Bottom