Criteria on Open a Form

L'apprentis

Redcifer
Local time
Today, 05:55
Joined
Jun 22, 2005
Messages
177
I was wondering if it was possible to add a parameter to the record source Query of a form depending on the value of an other field on the open event of the same form?
I was thinking to use 3 Sql statment SQL1, SQL2, SQL3, on the open event of the FrmOpen.
On Open then the RowSource of FrmOpen =SQL1
If field? = "A" Then
the RowSource of FrmOpen=SQL2
Else
the RowSource of FrmOpen=SQL3
End If
I did try but it doesn't work so I needed to know if it was possible to achieve this or not?
 
You can change RecordSource of your form even on the same form.
Let say you have unbound combobox "cboStatus" with values "A","B","C".
You have to select one of the existing value.

Private Sub cboStatus_AfterUpdate()

Me.RecordSource="Select * from YourTableName where Status=Forms!YourFormName.cboStatus"

End Sub

This give you basic idea how to use reference to a bound or unbound controls on any form , and perform dinamically changes on form's record source.
 

Users who are viewing this thread

Back
Top Bottom