Campo codificado en ACCESS 97

Dispongo de una BBDD Incidencias con un campo [Provincia] de tipo numérico.
Para dicho campo ajusto la
propiedad origen de fila= SELECT Provincias.[CLAVE PROV], Provincias.[NOMBRE PROV] FROM Provincias;
De manera que selecciono [NOMBRE PROV] en lista desplegable, guardando [CLAVE PROV] -numérico- en campo Provincia.
He creado una consulta sobre la BBDD, y el campo [Provincia] me lo muestra con el nombre "NAVARRA".
Pero si creo un informe basado en dicha consulta, me muestra la [Provincia] codificada "4".
¿Cómo hago para que en el informe me muestre el nombre de la provincia "NAVARRA" y no el código?

1 Respuesta

Respuesta
1
Una de las cosas que te recomiendo que utilices es un recordset, espero que lo tengas activo en el vba y te mando un pequeño código que tengo para mis clases esto te puede servir a utilizar los recordset:
Dim Dbs As Database
Dim RstCtrl As Recordset
Dim RstParte As Recordset
Dim RstPedido As Recordset
Dim StrSql As String
Dim Total As Long
Dim Cuenta As Long
Dim Parte As String
Ans = MsgBox("Confirme Procesamiento de pedido para evento '" & CboEvento.Text & "' ¿Desea Continuar?", vbYesNo _
, "'PROC0104' Confirme Proceso")
If Ans = vbNo Then
DoCmd.Close
Exit Sub
End If
' Inicia el proceso de recorrido del pedido
' Para cada parte se suman las cantidades pedidas para agregarse a un control
' El evento seleccionado se asigna al control ingresado
Set Dbs = CurrentDb
StrSql = "Select * from Pedidos"
Set RstPedido = Dbs.OpenRecordset(StrSql)
Total = 0
RstPedido.MoveFirst
Do While Not RstPedido.EOF
RstPedido.MoveNext
Total = Total + 1
Loop
Cuenta = 1
CtrlProgreso.Value = 0
RstPedido.MoveFirst
Do While Not RstPedido.EOF
Me.Caption = "Actualizando el Registro " & Cuenta & " de " & Total
CtrlProgreso.Value = (Cuenta / Total) * 100
If Len(RstPedido![P1]) = 1 Then
Parte = RstPedido![P1] & " "
Else
Parte = RstPedido![P1]
End If
Parte = Parte & RstPedido![P2] & RstPedido![P3] & RstPedido![P4] & Left(RstPedido![Color], 3)
StrSql = "Select * from QPAR0101 Where NoParte='" & Parte & "'"
Set RstParte = Dbs.OpenRecordset(StrSql)
If RstParte.RecordCount = 0 Then
' No existe el numero de parte, por lo tanto se crea en el catalogo de partes
If IsNull(RstPedido![Parte]) Then
GoTo ClaveNull
End If
RstParte.AddNew
RstParte![NoParte] = Parte
RstParte![P1] = Left(RstPedido![P1], 3)
RstParte![P2] = Left(RstPedido![P2], 3)
RstParte![P3] = Left(RstPedido![P3], 3)
RstParte![P4] = Left(RstPedido![P4], 2)
RstParte![Color] = Left(RstPedido![Color], 3)
RstParte![Descripcion] = RstPedido![Descripcio]
RstParte![Origen] = RstPedido![Origen]
If Not IsNull(RstPedido![CoP]) Or Not RstPedido![CoP] = "" Then
RstParte![CoP] = True
End If
RstParte![Programador] = RstPedido![Prog]
RstParte![PRs] = RstPedido![PR]
RstParte![Set] = RstPedido![Sets]
If SGUser = "" Or IsNull(SGUser) Then
DoCmd.OpenForm "FENT0101", , , , , acDialog
End If
RstParte![User] = SGUser
RstParte![Fecha] = Now()
RstParte.Update
RstParte.Close
End If
' Se busca un control para el numero de parte, evento y si no existe se crea.
StrSql = "Select * from QCON0101 Where NoParte= '" & Parte & "' and Evento='" & CboEvento & "'"
Set RstCtrl = Dbs.OpenRecordset(StrSql)
If RstCtrl.RecordCount = 0 Then
RstCtrl.AddNew
RstCtrl![NoParte] = Parte
RstCtrl![Evento] = CboEvento
RstCtrl![Cantidad] = RstPedido![Cantidad]
RstCtrl![Observacion] = RstPedido![Observa]
If SGUser = "" Or IsNull(SGUser) Then
DoCmd.OpenForm "FENT0101", , , , , acDialog
End If
RstCtrl![User] = SGUser
RstCtrl![Fecha] = Now()
RstCtrl.Update
RstCtrl.Close
Else
' En caso de que el control Exista se actualiza la cantidad solicitada para el evento seleccionado en la forma
RstCtrl.Edit
RstCtrl![Cantidad] = RstCtrl![Cantidad] + RstPedido![Cantidad]
If SGUser = "" Or IsNull(SGUser) Then
DoCmd.OpenForm "FENT0101", , , , , acDialog
End If
RstCtrl![Observacion] = RstCtrl![Observacion] & RstPedido![Observa]
RstCtrl![User] = SGUser
RstCtrl![Fecha] = Now()
RstCtrl.Update
RstCtrl.Close
End If
ClaveNull:
Cuenta = Cuenta + 1
RstPedido.MoveNext
Loop
DoCmd.Close
Si no tienes activo el recordset buelve a escribir para ke te diga como activarlo no se te olvide <<<puntuar>>>

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas