Change link chield & Maser fields

I

Iggv

is there a way i can change by codification the Link child Fields and LKink
Master Fields of a sub form.?
I have an db with telephone numbers.
In the form i have two list box, one where i chose by wich colum i want to
search

Private Sub LstOpciones_BeforeUpdate(Cancel As Integer)
Select Case LstOpciones
Case "Por Empresa"
LstBusqueda.RowSource = "Select Nombres.Empresa FROM Nombres
group by Nombres.Empresa"
Case "Por Apellido"
LstBusqueda.RowSource = "Select Nombres.Apellido FROM
Nombres group by Nombres.Apellido"
Case "Por Nombre"
LstBusqueda.RowSource = "Select Nombres.Nombre FROM
Nombres group by Nombres.Nombre"
End Select
End Sub

and the other show me the data of each colum,
and a botton that searchs the base
Private Sub Buscar_Click()
Select Case LstOpciones
Case "Por Empresa"
Me.Filter = "[EMPRESA] = " & Chr(34) & (LstBusqueda) & Chr(34)
Me.FilterOn = True
Case "Por Apellido"
Me.Filter = "[Apellido] = " & Chr(34) & (LstBusqueda) & Chr(34)
Me.FilterOn = True
Case "Por Nombre"
Me.Filter = "[Nombre] = " & Chr(34) & (LstBusqueda) & Chr(34)
Me.FilterOn = True

End Select
but it dosent work unles i change the child and master fields to EMPRESA,
NOMBRE or APELLIDO.
 
K

Ken Snell [MVP]

You can set the Link Master Fields and Link Child Fields properties of the
subform control (the control that holds the subform) via code:

Me.SubformName.LinkMasterFields = "EMPRESA"
Me.SubformName.LinkChildFields = "EMPRESA"

and so on. See VBA Help for more details.
 
I

Iggv

thanks, it works!!!
Ken Snell said:
You can set the Link Master Fields and Link Child Fields properties of the
subform control (the control that holds the subform) via code:

Me.SubformName.LinkMasterFields = "EMPRESA"
Me.SubformName.LinkChildFields = "EMPRESA"

and so on. See VBA Help for more details.

--

Ken Snell
<MS ACCESS MVP>

Iggv said:
is there a way i can change by codification the Link child Fields and LKink
Master Fields of a sub form.?
I have an db with telephone numbers.
In the form i have two list box, one where i chose by wich colum i want to
search

Private Sub LstOpciones_BeforeUpdate(Cancel As Integer)
Select Case LstOpciones
Case "Por Empresa"
LstBusqueda.RowSource = "Select Nombres.Empresa FROM Nombres
group by Nombres.Empresa"
Case "Por Apellido"
LstBusqueda.RowSource = "Select Nombres.Apellido FROM
Nombres group by Nombres.Apellido"
Case "Por Nombre"
LstBusqueda.RowSource = "Select Nombres.Nombre FROM
Nombres group by Nombres.Nombre"
End Select
End Sub

and the other show me the data of each colum,
and a botton that searchs the base
Private Sub Buscar_Click()
Select Case LstOpciones
Case "Por Empresa"
Me.Filter = "[EMPRESA] = " & Chr(34) & (LstBusqueda) & Chr(34)
Me.FilterOn = True
Case "Por Apellido"
Me.Filter = "[Apellido] = " & Chr(34) & (LstBusqueda) & Chr(34)
Me.FilterOn = True
Case "Por Nombre"
Me.Filter = "[Nombre] = " & Chr(34) & (LstBusqueda) & Chr(34)
Me.FilterOn = True

End Select
but it dosent work unles i change the child and master fields to EMPRESA,
NOMBRE or APELLIDO.
 
Top