Usuario
CREAR ARCHIVO .DAT DESDE VISUAL ACCESS 2010 - FORMATOS PERSONALIZADOS

Pregunta
-
Buenos días.
Cordial saludo.
Estoy creando archivos de tipo .dat, para subirlos a una herramienta especial de contabilidad, lo estoy creando en Acccess 2010.
El problema, es que necesito en fechas el siguiente formato: 30-sep-15 y las campos de numero: 44191940.51, siempre con dos decimales al final despues del punto, si no hay decimales debe colocar ceros (.00).
Cuando trato de aplicar estos formatos a la tabla de access antes de generar el archivo .dat, al generar el archivo .dat me desordena los datos, y no me sirven así para subirlo al otro aplicativo.
Muchas gracias a la persona que me pueda ayudar.
El siguiente es el código:
Private Sub PLANO_CSV_Click()
Dim rst As DAO.Recordset
Dim FORMATO_PC_CUOTA_MIXTO As String
Dim FORMATO_DESEMPLEO As String
Dim FORMATO_DESEMPLEO_CARDIF As String
Dim FORMATO_VIDA_GRUPO As String
Dim FORMATO_VIDA_INDIVIDUAL As String
FORMATO_PC_CUOTA_MIXTO = "Z:\Cierres\CierreAccess\Interfaces\FORMATO_PC_CUOTA_MIXTO.dat"
FORMATO_DESEMPLEO = "Z:\Cierres\CierreAccess\Interfaces\FORMATO_DESEMPLEO.dat"
FORMATO_DESEMPLEO_CARDIF = "Z:\Cierres\CierreAccess\Interfaces\FORMATO_DESEMPLEO_CARDIF.dat"
FORMATO_VIDA_GRUPO = "Z:\Cierres\CierreAccess\Interfaces\FORMATO_VIDA_GRUPO.dat"
FORMATO_VIDA_INDIVIDUAL = "Z:\Cierres\CierreAccess\Interfaces\FORMATO_VIDA_INDIVIDUAL.dat"
Set rst = CurrentDb.OpenRecordset("FORMATO_PC_CUOTA_MIXTO")
Set rst = CurrentDb.OpenRecordset("FORMATO_DESEMPLEO")
Set rst = CurrentDb.OpenRecordset("FORMATO_DESEMPLEO_CARDIF")
Set rst = CurrentDb.OpenRecordset("FORMATO_VIDA_GRUPO")
Set rst = CurrentDb.OpenRecordset("FORMATO_VIDA_INDIVIDUAL")
Open FORMATO_PC_CUOTA_MIXTO For Output As #1
Open FORMATO_DESEMPLEO For Output As #2
Open FORMATO_DESEMPLEO_CARDIF For Output As #3
Open FORMATO_VIDA_GRUPO For Output As #4
Open FORMATO_VIDA_INDIVIDUAL For Output As #5
'Write #1, "Status", "JL", "Origen", "Categoría", "FContable", "Mda", "FCreacion", "Por", "AF", "Debitos", "Creditos", "Cia", "Sucursal", "Cuenta", "Cc", "Pd", "Cn", "Rm", "Ng", "Ac", "Nit", "Prefijo", "Factura", "Documento", "Contexto", "Descripción", "FechaDoc", "Lote", "Asiento", "ClaseDoc", "BaseRet", "Referencia", "Comodín"
While Not rst.EOF
Write #1, rst![Status], rst![JL], rst![Origen], rst![Categoría], rst![FContable], rst![Mda], rst![FCreacion], rst![Por], rst![AF], rst![Debitos], rst![Creditos], rst![Cia], rst![Sucursal], rst![Cuenta], rst![Cc], rst![Pd], rst![Cn], rst![Rm], rst![Ng], rst![Ac], rst![Nit], rst![Prefijo], rst![Factura], rst![Documento], rst![Contexto], rst![Descripción], rst![FechaDoc], rst![Lote], rst![Asiento], rst![ClaseDoc], rst![BaseRet], rst![Referencia], rst![Comodín]
Write #2, rst![Status], rst![JL], rst![Origen], rst![Categoría], rst![FContable], rst![Mda], rst![FCreacion], rst![Por], rst![AF], rst![Debitos], rst![Creditos], rst![Cia], rst![Sucursal], rst![Cuenta], rst![Cc], rst![Pd], rst![Cn], rst![Rm], rst![Ng], rst![Ac], rst![Nit], rst![Prefijo], rst![Factura], rst![Documento], rst![Contexto], rst![Descripción], rst![FechaDoc], rst![Lote], rst![Asiento], rst![ClaseDoc], rst![BaseRet], rst![Referencia], rst![Comodín]
Write #3, rst![Status], rst![JL], rst![Origen], rst![Categoría], rst![FContable], rst![Mda], rst![FCreacion], rst![Por], rst![AF], rst![Debitos], rst![Creditos], rst![Cia], rst![Sucursal], rst![Cuenta], rst![Cc], rst![Pd], rst![Cn], rst![Rm], rst![Ng], rst![Ac], rst![Nit], rst![Prefijo], rst![Factura], rst![Documento], rst![Contexto], rst![Descripción], rst![FechaDoc], rst![Lote], rst![Asiento], rst![ClaseDoc], rst![BaseRet], rst![Referencia], rst![Comodín]
Write #4, rst![Status], rst![JL], rst![Origen], rst![Categoría], rst![FContable], rst![Mda], rst![FCreacion], rst![Por], rst![AF], rst![Debitos], rst![Creditos], rst![Cia], rst![Sucursal], rst![Cuenta], rst![Cc], rst![Pd], rst![Cn], rst![Rm], rst![Ng], rst![Ac], rst![Nit], rst![Prefijo], rst![Factura], rst![Documento], rst![Contexto], rst![Descripción], rst![FechaDoc], rst![Lote], rst![Asiento], rst![ClaseDoc], rst![BaseRet], rst![Referencia], rst![Comodín]
Write #5, rst![Status], rst![JL], rst![Origen], rst![Categoría], rst![FContable], rst![Mda], rst![FCreacion], rst![Por], rst![AF], rst![Debitos], rst![Creditos], rst![Cia], rst![Sucursal], rst![Cuenta], rst![Cc], rst![Pd], rst![Cn], rst![Rm], rst![Ng], rst![Ac], rst![Nit], rst![Prefijo], rst![Factura], rst![Documento], rst![Contexto], rst![Descripción], rst![FechaDoc], rst![Lote], rst![Asiento], rst![ClaseDoc], rst![BaseRet], rst![Referencia], rst![Comodín]
rst.MoveNext
Wend
Close #1
Close #2
Close #3
Close #4
Close #5
rst.Close: Set rst = Nothing
MsgBox "El archivo " & FORMATO_PC_CUOTA_MIXTO & " ha sido creado con éxito.", vbInformation, "Creación de Archivo DAT"
Todas las respuestas
-
Hola
¿Por qué no creas una variable de tipo string en la cual construyes cada linea, y justo al final de terminar de concatenar los campos, lo escribes en el fichero?
Otra cosa, en la cabecera del cuadro donde escribes este post tienes una herramienta de "Insertar bloque de código", úsala para insertar código de forma más legible, formateado.
Saludos,
José Mª Fueyo [MS MVP Access]
-
-
Muchas gracias por sus respuestas.
Ya he creado las funciones para los formatos, pero no he podido conseguir que me ordene el archivo plano o que no me cambie el orden.
estoy utilizando el siguiente codigo:
rst.Index = rst ![Descripción]
Pero sale el error que no es un indice en esta tabla.
este campo: Descripcion, esta indexado con duplicados, pero no la toma.
Gracias.
-
-
-
Hola
Set rst = CurrentDb.OpenRecordset("FORMATO_PC_CUOTA_MIXTO")
Set rst = CurrentDb.OpenRecordset("FORMATO_DESEMPLEO")
Set rst = CurrentDb.OpenRecordset("FORMATO_DESEMPLEO_CARDIF")
Set rst = CurrentDb.OpenRecordset("FORMATO_VIDA_GRUPO")
Set rst = CurrentDb.OpenRecordset("FORMATO_VIDA_INDIVIDUAL")Estas lineas, estás reasignando constantemente la variable de tipo recordset. ¿Son tablas, consultas...?, ¿que son?
Salu2,
José Mª Fueyo
- Editado José Mª Fueyo viernes, 30 de octubre de 2015 8:15
-
Buenos días José.
Cordial saludo.
Son Tablas, y si tenían ese error, solamente estaban apuntando a un solo recordset, pero ya la corregí quedo asi:
Set rst1 = CurrentDb.OpenRecordset("FORMATO_PC_CUOTA_MIXTO") Set rst2 = CurrentDb.OpenRecordset("FORMATO_DESEMPLEO") Set rst3 = CurrentDb.OpenRecordset("FORMATO_DESEMPLEO_CARDIF") Set rst4 = CurrentDb.OpenRecordset("FORMATO_VIDA_GRUPO") Set rst5 = CurrentDb.OpenRecordset("FORMATO_VIDA_INDIVIDUAL")
Gracias por responder, disculpe, soy nuevo en programación, por lo que cometo muchos errores.
-