Zum Hauptinhalt gehen

Suche

Suche

Problem Adding Value To Date

Kommentare

1 Kommentar

  • Avatar
    Legacy Poster

    For the benefit of anybody reading this, I found the problem.  The script runs more than once, and the mismatch was because it was catching a blank or "" entry.

     

    My final script looked like this:

     

    dataSource = "EPICORSQL01"
    initialCatalog = "Epicor10" 
    tableName = "dbo.Part" 
    columnName = "LotShelfLife" 
    
    Set objCon = CreateObject("ADODB.Connection")
    
    objCon.ConnectionString = "Provider=SQLOLEDB;Data Source=" & dataSource & ";Initial Catalog=" & initialCatalog & ";Integrated Security=SSPI;Persist Security Info=False;"
    objCon.Open
    
    strCon = "SELECT " & columnName & " FROM " & Tablename & " WHERE PartNum = '" & Format.NamedSubStrings("EpiPartNum").Value & "'"
    
    Set rs = CreateObject("ADODB.Recordset")
    Set rs = objCon.Execute(strCon)
    
    options=0
    Do Until rs.EOF
    	If Len(options)>0 Then options = options
    	options = rs(columnName).value
    	rs.MoveNext
    Loop
    
    objCon.Close
    Set objCon = Nothing
    
    If Format.NamedSubStrings("AlterDays").Value <> "" and Format.NamedSubStrings("AlterDays").Value <> "-"  Then
    	AlteredDays = CInt(Format.NamedSubStrings("AlterDays").Value) + options
    Else
    	AlteredDays = options
    End If
    
    dteUseBy = DateAdd("d", AlteredDays, Date)
    strUseBy = Right("0" & Day(dteUseBy), 2) & " " & MonthName(Month(dteUseBy),true) & " " & Right(Year(dteUseBy), 2)
    
    Value=strUseBy
    
    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.