
01/08/2009, 01:05
|
| | Fecha de Ingreso: julio-2009
Mensajes: 7
Antigüedad: 15 años, 9 meses Puntos: 0 | |
Respuesta: Como seleccionar algunos registros de varios campos Trate de solucionarlo, aqui va mi programa:
Option Compare Database
Option Explicit
Public Sub Command0_Click()
Dim lngFichero As Long
Dim strFichero As String
Dim MiRS As DAO.Recordset 'Variable de recordset
Dim sRegistro As String 'Para guardar los datos
Dim sql As String
Dim strCodestacion As String
Dim i As Integer
For i = 1 To 18
strFichero = "D:\CIP"
strFichero = strFichero & "\TMAX" + LTrim(Str(i)) + ".txt"
sql = "SELECT * FROM Datos_SenamhiB order by codestacion, dia08"
Set MiRS = CurrentDb.OpenRecordset(sql, dbOpenForwardOnly)
lngFichero = FreeFile(1)
strCodestacion = ""
sRegistro = ""
Open strFichero For Output As #lngFichero
If Not MiRS.EOF And Not MiRS.BOF Then
Do While Not MiRS.EOF
If Val(MiRS("dia08")) >= i And Val(MiRS("dia08")) <= 12 * i Then
If strCodestacion = Trim(MiRS!Codestacion) Then
sRegistro = sRegistro + Space(3) + Format(Trim(MiRS!tmax), "##.00")
If Val(MiRS("dia08")) = 12*i Then
Print #lngFichero, Format(sRegistro, "##.00")
End If
Else
If strCodestacion = "" Then
strCodestacion = Trim(MiRS!Codestacion)
'Print #lngFichero, strCodestacion + Space(3) + Trim(MiRS!Lat) + Space(3) + Trim(MiRS!Lon) + Space(3) + Trim(MiRS!Altitud)
Print #lngFichero, Format(strCodestacion, "000###") + Space(3) + Format(Trim(MiRS!Lat), "##.0000") + Space(3) + Format(Trim(MiRS!Lon), "##.0000") + Space(3) + Trim(MiRS!Altitud)
sRegistro = Format(Trim(MiRS!tmax), "##.00")
Else
strCodestacion = Trim(MiRS!Codestacion)
sRegistro = Format(Trim(MiRS!tmax), "##.00")
'Print #lngFichero, strCodestacion + Space(3) + Trim(MiRS!Lat) + Space(3) + Trim(MiRS!Lon) + Space(3) + Trim(MiRS!Altitud)
Print #lngFichero, Format(strCodestacion, "000###") + Space(3) + Format(Trim(MiRS!Lat), "##.0000") + Space(3) + Format(Trim(MiRS!Lon), "##.0000") + Space(3) + Trim(MiRS!Altitud)
End If
End If
End If
MiRS.MoveNext
Loop
End If
Close #lngFichero
MiRS.Close
Set MiRS = Nothing
Next i
End Sub
Ya el programa pone los datos como les dije pero falta que lo alinee, respetando unidad decena y centena, solo los alinea bien cuanto es una decena es decie 10 10.6 pero cuando viene una unidad 5 o 5.4 no respeta la ubicacion de la unidad, el pinto y el decimal.
Gracias! |