change or impose query on form

  • Thread starter Thread starter Vsn
  • Start date Start date
V

Vsn

Hi All,

Just wondering if I can change the query of a form (Form1) with code on
(Form2).

I would like to use the same form, to show diffrend data (columns in
continious form) on various options on a second from.

Your advice will be appriciated.

Thx,
Ludovic
 
No need for code. Copy and paste the form under the new name. Open the
query in design view and change the record source. Save.
 
Karl,

'No need for code'; Probably depends on what the final goal is.
What if you do not know the number of columns the end user will create?
What if you like to reduce the number of simple input forms, by having
one form doing the lot
It will save closing and opening a form aswell, the user just sees, as a
result of his selection change on a form, change the data on another.

I think to remember i have seen some code which could just do this, but dont
know where any more.

Thx,
Ludovic
 
Below code might be a solution for interested people:-

Reading throug this news group gave me the idea again.

Private Sub cmdChangeQuery_Click()
Static intAction As Integer
Dim stgSQL As String

intAction = intAction + 1

If intAction = 2 Then intAction = 0

Select Case intAction
Case 0
stgSQL = "SELECT tblData.fID AS One, tblData.fName AS Two FROM tblData
ORDER BY tblData.fName;"
Me.Label0.Caption = "Rec ID"
Me.Label1.Caption = "Name"
Case 1
stgSQL = "SELECT tblData.fName AS One, tblData.fCity AS Two FROM tblData
ORDER BY tblData.fName;"
Me.Label0.Caption = "Name"
Me.Label1.Caption = "City"
Case Else
Stop
End Select

Forms!frmTest.RecordSource = stgSQL

End Sub



Ludovic
 
Back
Top