thanks
the problem is that some forms recordsource's is a table, other are based on queries.
Some times i have calculated fields, so i'm building a complex structure
Code:
Private Sub Form_Open(Cancel As Integer)
If Me.OpenArgs <> "" Then
Me.Caption = Mid(Me.OpenArgs, InStr(Me.OpenArgs, "\") + 1)
Origin = Left(Me.OpenArgs, InStr(Me.OpenArgs, "\") - 1)
MsgBox (Origin)
Me.FldFilt.RowSource = Origin
If Origin Like "SELECT*" Then
If Origin Like "*order by*" Then
FldOrigin = Mid(Origin, InStr(Origin, "From"), (Len(Origin) - InStr(Origin, "FROM") - 1) - (Len(Origin) - InStr(Origin, "Order by"))) ' estraggo la stringa sql fino all'eventuale "order by"
MsgBox (FldOrigin)
Else
FldOrigin = Mid(Origin, InStr(Origin, "From"))
End If
Else
FldOrigin = Origin
End If
End If
End Sub
openargs is the concatenation of the name of the form i want to filter and its recordsource
Code:
Private Sub Value1CB_GotFocus() If FldOrigin = Origin Then
Me.Value1CB.RowSource = "SELECT " & "[" & Me.FldFilt & "]" & " FROM " & "[" & FldOrigin & "]"
Else
Me.Value1CB.RowSource = "SELECT " & "[" & Me.FldFilt & "]" & " " & FldOrigin
End If
End Sub
actually is working pretty good right now