change or impose query on form

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
 
K

KARL DEWEY

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.
 
V

Vsn

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
 
V

Vsn

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top