I am having trouble pulling records from the SO Detail table and inserting them into an access table. The problem arises because if a record has not value in the CURDUE_28 field, this creates an invalid date error. However, if the CURDUE_28 field is empty then I can use the value from the SHPDTE_28 field. This seems to work OK on the insert but it still raises a Pervasive error (Invalid date, time or timestamp value) when moving from onw record to the next.
In access, when selecting records I could do something like:
SELECT IIF(not isdate(CURDUE_28), SHPDTE_28, CURDUE_28) AS recDate FROM "SO Detail"
Can I do something like that in MAX - or can you suggest another solution.
I have tried simply testing the record before I write it to access and the record goes in OK but an error arises when moving to the next reocrd. The code for this is below (VBScript):
do while not MaxRs.EOF
if not isDate(MaxRs("CURDUE_28"
) then
duedate = MaxRs("SHPDTE_28"
else
duedate = MaxRs("CURDUE_28"
end if
' Generate the INSERT Sql command
sql = "INSERT INTO ""SO Detail"" (ORDNUM_28, LINNUM_28, DELNUM_28, STATUS_28, CUSTID_28, PRTNUM_28, CURDUE_28, CURQTY_28, SHPQTY_28, DUEQTY_28, PRICE_28) "
sql = sql & "VALUES ('" & output(MaxRs("ORDNUM_28"
) & "', '" & output(MaxRs("LINNUM_28"
) & "', '"
sql = sql & output(MaxRs("DELNUM_28"
) & "', '" & output(MaxRs("STATUS_28"
) & "', '" & output(MaxRs("CUSTID_28"
) & "', '" & output(MaxRs("PRTNUM_28"
)
sql = sql & "', #" & duedate & "#, " & output(MaxRs("CURQTY_28"
) & ", " & output(MaxRs("SHPQTY_28"
)
sql = sql & ", " & output(MaxRs("DUEQTY_28"
) & ", " & output(MaxRs("PRICE_28"
) & "
"
' Insert the data
AccConn.Execute sql, , 1
' Check for Errors
Call CheckForErrors(AccConn, -6)
' Increment the affecte rows counter
intRows = intRows + 1
' Move to the next row in the recordset
MaxRs.MoveNext (Error message gets flagged at this line)
loop
Any help you can give me would be appreciated Mise Le Meas,
Mighty
In access, when selecting records I could do something like:
SELECT IIF(not isdate(CURDUE_28), SHPDTE_28, CURDUE_28) AS recDate FROM "SO Detail"
Can I do something like that in MAX - or can you suggest another solution.
I have tried simply testing the record before I write it to access and the record goes in OK but an error arises when moving to the next reocrd. The code for this is below (VBScript):
do while not MaxRs.EOF
if not isDate(MaxRs("CURDUE_28"
duedate = MaxRs("SHPDTE_28"
else
duedate = MaxRs("CURDUE_28"
end if
' Generate the INSERT Sql command
sql = "INSERT INTO ""SO Detail"" (ORDNUM_28, LINNUM_28, DELNUM_28, STATUS_28, CUSTID_28, PRTNUM_28, CURDUE_28, CURQTY_28, SHPQTY_28, DUEQTY_28, PRICE_28) "
sql = sql & "VALUES ('" & output(MaxRs("ORDNUM_28"
sql = sql & output(MaxRs("DELNUM_28"
sql = sql & "', #" & duedate & "#, " & output(MaxRs("CURQTY_28"
sql = sql & ", " & output(MaxRs("DUEQTY_28"
' Insert the data
AccConn.Execute sql, , 1
' Check for Errors
Call CheckForErrors(AccConn, -6)
' Increment the affecte rows counter
intRows = intRows + 1
' Move to the next row in the recordset
MaxRs.MoveNext (Error message gets flagged at this line)
loop
Any help you can give me would be appreciated Mise Le Meas,
Mighty