publicado el 20 de junio13 años Hola Amigos del Foro Es mi deseo agradecer la oportunidad que dan en este foro de aprender de muchos de ustedes y a su vez aportar algo de los pocos conocimientos. En esta oportunidad tengo un inconveniente con la conexión Excel Access - He tratado de crear la macro de conexión pero solo me da errores. Donde está la situación creo es que la BD Access está en un equipo remoto. No he podido establecer la cadena de conexión bien... en fín he intentado con múltiples opciones y nada Este es mi codigo: , Private Sub CmBtnEnviar_Click() Dim strSQL As String, _ CuadroTexto As Control 'me aseguro de que todos los cuadros de texto están rellenos 'For Each CuadroTexto In Me.Controls 'If Left(CuadroTexto.Name, 3) = "txt" Then 'If SiEsNulo(CuadroTexto, "") = "" Then ' MsgBox "El cuadro de texto " & CuadroTexto.Name & " está vacío", vbCritical + vbOKOnly, "ATENCION" 'Exit Sub 'End If 'End If 'Next ' construyo la select para envíar los datos a la base de datos strSQL = "INSERT INTO " & frmTask.txtTabla.Text strSQL = strSQL & "([idConsecutivo], " strSQL = strSQL & "[fecha], " strSQL = strSQL & "[ObjetoContractual], " strSQL = strSQL & "[ValorProgramadoaContratar], " strSQL = strSQL & "[identificadorPresupuestal], " strSQL = strSQL & "[NombreIdentificador], " strSQL = strSQL & "[NumeroContrato], " strSQL = strSQL & "[ObjetoContracto], " strSQL = strSQL & "[ValorContrato], " strSQL = strSQL & "[NombreContratista], " strSQL = strSQL & "[FechaSuscripcion], " strSQL = strSQL & "[TipoDocumento], " strSQL = strSQL & "[CertificadoDisponiblidad], " strSQL = strSQL & "[CertificadoRegistroP], " strSQL = strSQL & "[Producto], " strSQL = strSQL & "[unidadMedida], " strSQL = strSQL & "[CantidadP], " strSQL = strSQL & "[ValorUnitarioP], " strSQL = strSQL & "[TiempoP], " strSQL = strSQL & "[TotalP], " strSQL = strSQL & "[CantidadC], " strSQL = strSQL & "[ValorUnitarioC], " strSQL = strSQL & "[TiempoC], " strSQL = strSQL & "[TotalC], " strSQL = strSQL & "[CantidadE], " strSQL = strSQL & "[ValorUnitarioE], " strSQL = strSQL & "[TiempoE], " strSQL = strSQL & "[TotalE] );" strSQL = strSQL & " SELECT '" & frmTask.LblTraeConsecutivo & "', '" strSQL = strSQL & Format(frmTask.LblFecha, "mm/dd/yy") & "#" strSQL = strSQL & frmTask.LblObjetoContractual & "', '" strSQL = strSQL & frmTask.LblValorPContratar & "', '" strSQL = strSQL & frmTask.CmBxRubroPresupuestal & "', '" strSQL = strSQL & frmTask.TxBxNombreRubro & "', '" strSQL = strSQL & frmTask.LblNumeroContrato & "', '" strSQL = strSQL & frmTask.LblObjetoContratoFC & "', '" strSQL = strSQL & frmTask.LblValorContrato & "', '" strSQL = strSQL & frmTask.LblContratistaoProveedor & "', '" strSQL = strSQL & Format(frmTask.LblFechaSuscripcion, "mm/dd/yy") & "#" strSQL = strSQL & frmTask.LblTipoDocumento & "', '" strSQL = strSQL & frmTask.LblCDP & "', '" strSQL = strSQL & frmTask.LblCRP & "', '" strSQL = strSQL & frmTask.Productos1 & "', '" strSQL = strSQL & frmTask.UnidadMedida1 & "', '" strSQL = strSQL & frmTask.CantidadP1 & "', '" strSQL = strSQL & frmTask.ValorUnitarioP1 & "', '" strSQL = strSQL & frmTask.TiempoP1 & "', '" strSQL = strSQL & frmTask.TotalPCVT1 & "', '" strSQL = strSQL & frmTask.CantidadC1 & "', '" strSQL = strSQL & frmTask.ValorUnitarioC1 & "', '" strSQL = strSQL & frmTask.TiempoC1 & "', '" strSQL = strSQL & frmTask.TotalCCVT1 & "', '" strSQL = strSQL & frmTask.CantidadE1 & "', '" strSQL = strSQL & frmTask.ValorUnitarioE1 & "', '" strSQL = strSQL & frmTask.TiempoE1 & "', '" strSQL = strSQL & frmTask.TotalECVT1 & "', '" Dim direccion As Control direccion = "\\172.16.9.31\ArchivosICBF\PACCOR\EjecucionPACCO2012\General\BDPACCOE.mdb" ' ejecuto la consulta para insertar los datos en la tabla ConsultaAccionEnBD direccion, strSQL End Sub Como el archivo es muy grande me toco subirlo en un enlace externo espero que por esto mi tema no sea cerrado. Este es el link: http://sdrv.ms/Pv0Oqq Que puedo estar haciendo mal..? Agradezco sus orientaciones
Hola Amigos del Foro
Es mi deseo agradecer la oportunidad que dan en este foro de aprender de muchos de ustedes y a su vez aportar algo de los pocos conocimientos.
En esta oportunidad tengo un inconveniente con la conexión Excel Access -
He tratado de crear la macro de conexión pero solo me da errores.
Donde está la situación creo es que la BD Access está en un equipo remoto.
No he podido establecer la cadena de conexión bien... en fín he intentado con múltiples opciones y nada
Este es mi codigo:
Private Sub CmBtnEnviar_Click()
Dim strSQL As String, _
CuadroTexto As Control
'me aseguro de que todos los cuadros de texto están rellenos
'For Each CuadroTexto In Me.Controls
'If Left(CuadroTexto.Name, 3) = "txt" Then
'If SiEsNulo(CuadroTexto, "") = "" Then
' MsgBox "El cuadro de texto " & CuadroTexto.Name & " está vacío", vbCritical + vbOKOnly, "ATENCION"
'Exit Sub
'End If
'End If
'Next
' construyo la select para envíar los datos a la base de datos
strSQL = "INSERT INTO " & frmTask.txtTabla.Text
strSQL = strSQL & "([idConsecutivo], "
strSQL = strSQL & "[fecha], "
strSQL = strSQL & "[ObjetoContractual], "
strSQL = strSQL & "[ValorProgramadoaContratar], "
strSQL = strSQL & "[identificadorPresupuestal], "
strSQL = strSQL & "[NombreIdentificador], "
strSQL = strSQL & "[NumeroContrato], "
strSQL = strSQL & "[ObjetoContracto], "
strSQL = strSQL & "[ValorContrato], "
strSQL = strSQL & "[NombreContratista], "
strSQL = strSQL & "[FechaSuscripcion], "
strSQL = strSQL & "[TipoDocumento], "
strSQL = strSQL & "[CertificadoDisponiblidad], "
strSQL = strSQL & "[CertificadoRegistroP], "
strSQL = strSQL & "[Producto], "
strSQL = strSQL & "[unidadMedida], "
strSQL = strSQL & "[CantidadP], "
strSQL = strSQL & "[ValorUnitarioP], "
strSQL = strSQL & "[TiempoP], "
strSQL = strSQL & "[TotalP], "
strSQL = strSQL & "[CantidadC], "
strSQL = strSQL & "[ValorUnitarioC], "
strSQL = strSQL & "[TiempoC], "
strSQL = strSQL & "[TotalC], "
strSQL = strSQL & "[CantidadE], "
strSQL = strSQL & "[ValorUnitarioE], "
strSQL = strSQL & "[TiempoE], "
strSQL = strSQL & "[TotalE] );"
strSQL = strSQL & " SELECT '" & frmTask.LblTraeConsecutivo & "', '"
strSQL = strSQL & Format(frmTask.LblFecha, "mm/dd/yy") & "#"
strSQL = strSQL & frmTask.LblObjetoContractual & "', '"
strSQL = strSQL & frmTask.LblValorPContratar & "', '"
strSQL = strSQL & frmTask.CmBxRubroPresupuestal & "', '"
strSQL = strSQL & frmTask.TxBxNombreRubro & "', '"
strSQL = strSQL & frmTask.LblNumeroContrato & "', '"
strSQL = strSQL & frmTask.LblObjetoContratoFC & "', '"
strSQL = strSQL & frmTask.LblValorContrato & "', '"
strSQL = strSQL & frmTask.LblContratistaoProveedor & "', '"
strSQL = strSQL & Format(frmTask.LblFechaSuscripcion, "mm/dd/yy") & "#"
strSQL = strSQL & frmTask.LblTipoDocumento & "', '"
strSQL = strSQL & frmTask.LblCDP & "', '"
strSQL = strSQL & frmTask.LblCRP & "', '"
strSQL = strSQL & frmTask.Productos1 & "', '"
strSQL = strSQL & frmTask.UnidadMedida1 & "', '"
strSQL = strSQL & frmTask.CantidadP1 & "', '"
strSQL = strSQL & frmTask.ValorUnitarioP1 & "', '"
strSQL = strSQL & frmTask.TiempoP1 & "', '"
strSQL = strSQL & frmTask.TotalPCVT1 & "', '"
strSQL = strSQL & frmTask.CantidadC1 & "', '"
strSQL = strSQL & frmTask.ValorUnitarioC1 & "', '"
strSQL = strSQL & frmTask.TiempoC1 & "', '"
strSQL = strSQL & frmTask.TotalCCVT1 & "', '"
strSQL = strSQL & frmTask.CantidadE1 & "', '"
strSQL = strSQL & frmTask.ValorUnitarioE1 & "', '"
strSQL = strSQL & frmTask.TiempoE1 & "', '"
strSQL = strSQL & frmTask.TotalECVT1 & "', '"
Dim direccion As Control
direccion = "\\172.16.9.31\ArchivosICBF\PACCOR\EjecucionPACCO2012\General\BDPACCOE.mdb"
' ejecuto la consulta para insertar los datos en la tabla
ConsultaAccionEnBD direccion, strSQL
End Sub
Como el archivo es muy grande me toco subirlo en un enlace externo espero que por esto mi tema no sea cerrado.
Este es el link:
http://sdrv.ms/Pv0Oqq
Que puedo estar haciendo mal..?
Agradezco sus orientaciones