Can we create new table base on subform query (1 Viewer)

rio

Registered User.
Local time
Today, 17:19
Joined
Jun 3, 2008
Messages
124
hi.

in my form I used 2 combobox to show and hide column in subform. so can I make new table for this subform (only show column)

This is my combo code :

Code:
Private Sub hideColumn_Change()
    Select Case Me.hideColumn
    Case "Test 1"
        Me.Subform.Form.Test1.ColumnHidden = True
    Case "Test 2"
        Me.Subform.Form.Test2.ColumnHidden = True
    Case "Test 3"
        Me.Subform.Form.Test3.ColumnHidden = True
    End Select
End Sub

Private Sub showColumn_Change()
    Select Case Me.showColumn
    Case "Test 1"
        Me.Subform.Form.Test1.ColumnHidden = False
    Case "Test 2"
        Me.Subform.Form.Test2.ColumnHidden = False
    Case "Test 3"
        Me.Subform.Form.Test3.ColumnHidden = False
    End Select
End Sub

:confused::confused:
 

llkhoutx

Registered User.
Local time
Today, 04:19
Joined
Feb 26, 2001
Messages
4,018
I would dynamically build the SQL string to use in a make table query.

Why not just hide controtls on he subform?
 

vbaInet

AWF VIP
Local time
Today, 10:19
Joined
Jan 22, 2010
Messages
26,374
hi.

in my form I used 2 combobox to show and hide column in subform. so can I make new table for this subform (only show column)

This is my combo code :

Code:
Private Sub hideColumn_Change()
    Select Case Me.hideColumn
    Case "Test 1"
        Me.Subform.Form.Test1.ColumnHidden = True
    Case "Test 2"
        Me.Subform.Form.Test2.ColumnHidden = True
    Case "Test 3"
        Me.Subform.Form.Test3.ColumnHidden = True
    End Select
End Sub

Private Sub showColumn_Change()
    Select Case Me.showColumn
    Case "Test 1"
        Me.Subform.Form.Test1.ColumnHidden = False
    Case "Test 2"
        Me.Subform.Form.Test2.ColumnHidden = False
    Case "Test 3"
        Me.Subform.Form.Test3.ColumnHidden = False
    End Select
End Sub
:confused::confused:
Also, duplication of data. Can you not create a SELECT query to extract that column only?

Unless you have your reasons why you want to build a new table for that column?
 

rio

Registered User.
Local time
Today, 17:19
Joined
Jun 3, 2008
Messages
124
my plan is to create graph from that selection subform. i want the graph only show the select column. so what i know is....to make a graph we have to link it with a table. that why i want to make new table.

so...
llkhoutx and vbaInet..... any suggestion?
 

vbaInet

AWF VIP
Local time
Today, 10:19
Joined
Jan 22, 2010
Messages
26,374
What you're doing is hiding the column in the Datasheet VIEW not the record source. You need to devise a way of hiding the field instead. Think about sql, think about recordsets, think about INSERT.
 

rio

Registered User.
Local time
Today, 17:19
Joined
Jun 3, 2008
Messages
124
Thanks...vbaInet
I solved it by using this code.
Code:
Private Sub Command9_Click()
Dim sqlStr As String

sqlStr = "SELECT " & "Table1.Test" & ", " & "Table1." & Me!Test 1 & ", " & "Table1." & Me!Test 2 & " INTO " & "Tablelain " & "FROM " & "Table1;"
DoCmd.SetWarnings False
DoCmd.RunSQL sqlStr
DoCmd.SetWarnings True

End Sub
 

vbaInet

AWF VIP
Local time
Today, 10:19
Joined
Jan 22, 2010
Messages
26,374
I knew you had the prowess to come up with a solution from the ideas given.

Great job rio.
 

Users who are viewing this thread

Top Bottom