0% found this document useful (0 votes)
5 views3 pages

Daily Well Parameters Script

The document contains a VBA script that generates a file name for well parameters based on the date, opens the corresponding Excel workbook, and populates a database with data from the workbook. It checks for empty or invalid values and assigns default values when necessary. Finally, it saves the updated database and displays a message box indicating the completion of the update.

Uploaded by

Youcef Slimi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Daily Well Parameters Script

The document contains a VBA script that generates a file name for well parameters based on the date, opens the corresponding Excel workbook, and populates a database with data from the workbook. It checks for empty or invalid values and assigns default values when necessary. Finally, it saves the updated database and displays a message box indicating the completion of the update.

Uploaded by

Youcef Slimi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

If Month(FileCountr) < 10 Then

If Day(FileCountr) < 10 Then


FileString = "well parameters " & CStr(Year(FileCountr)) & "-0" &
CStr(Month(FileCountr)) & "-0" & CStr(Day(FileCountr)) & ".xlsx"
Else
FileString = "well parameters " & CStr(Year(FileCountr)) & "-0" &
CStr(Month(FileCountr)) & "-" & CStr(Day(FileCountr)) & ".xlsx"
End If
Else
If Day(FileCountr) < 10 Then
FileString = "well parameters " & CStr(Year(FileCountr)) & "-" &
CStr(Month(FileCountr)) & "-0" & CStr(Day(FileCountr)) & ".xlsx"
Else
FileString = "well parameters " & CStr(Year(FileCountr)) & "-" &
CStr(Month(FileCountr)) & "-" & CStr(Day(FileCountr)) & ".xlsx"
End If
End If

With ews
.[Link] [Link] & "\Daily well parameters\" &
FileString
.Visible = True
End With

With rst
.Open "DAI_WellParameter", cnn, adOpenKeyset, adLockOptimistic,
adCmdTableDirect
[Link](1).Select
k=1
j=1
DoTotal = [Link]([Link]("C9:C999")) + 1
Do Until (k = DoTotal)
If Not IsEmpty([Link](j + 8, 3)) Then
.AddNew
.Fields("WH_Date").Value = FileCountr
.Fields("WH_Time").Value = [Link](j + 8, 3)
If Not IsEmpty([Link](j + 8, 2)) Then
WellName = [Link](j + 8, 2)
End If
.Fields("WH_WellID").Value = WellName
If IsEmpty([Link](j + 8, 4)) Or [Link](j + 8, 4) = 0 Or Not
IsNumeric([Link](j + 8, 4)) Then
.Fields("WH_Choke").Value = 0
.Fields("WH_THP").Value = 0
.Fields("WH_THT").Value = 0
.Fields("WH_FLP").Value = 0
.Fields("WH_FLT").Value = 0
.Fields("WH_AAnnP").Value = 0
.Fields("WH_BAnnP").Value = 0
.Fields("WH_CAnnP").Value = 0
.Fields("WH_Scale").Value = 0
.Fields("WH_Corrs").Value = 0
.Fields("WH_Waxin").Value = 0
.Fields("WH_Dilut").Value = 0
Else
.Fields("WH_Choke").Value = [Link](j + 8, 4)
.Fields("WH_THP").Value = [Link](j + 8, 5)
.Fields("WH_THT").Value = [Link](j + 8, 6)
.Fields("WH_FLP").Value = [Link](j + 8, 7)
.Fields("WH_FLT").Value = [Link](j + 8, 8)
.Fields("WH_AAnnP").Value = [Link](j + 8, 9)
.Fields("WH_BAnnP").Value = [Link](j + 8, 10)
.Fields("WH_CAnnP").Value = [Link](j + 8, 11)
.Fields("WH_Scale").Value = [Link](j + 8, 12)
.Fields("WH_Corrs").Value = [Link](j + 8, 13)
.Fields("WH_Waxin").Value = [Link](j + 8, 14)
.Fields("WH_Dilut").Value = [Link](j + 8, 15)
End If
.Fields("WH_Commnt").Value = [Link](j + 8, 16)
k=k+1
End If
j=j+1
Loop
.Save
.Close
End With
Next i
MsgBox "Well parameters database to updated to " & ReadToDate
[Link]
End If
End Function

You might also like