B
Bre-x
Hi,
I have a table where there's a "R" field (Yes/No Type)
For every record where R equals to -1 I have a function that do "something"
I am able to accomplish this by creating a query with a function on it
But couldn't I accomplish this with a while..loop or for....each statement?
How to I read my table and go into each record and read the "R" Field?
Thank you All
Bre-x
'Here is the Query
SELECT SOL.SONUM, SOL.L, SOL.MS, SOL.R, SOL.RQTY,
doSHP([SONUM],[L],[R],[RQTY]) AS DoSHPFunction INTO Temp
FROM SOL;
'Here is the Function
Function doSHP(SONUM, SOLINE, R, RQTY)
If R = -1 Then
If RQTY = 0 Then
MsgBox "Sales Order: " & SONUM & " " & Chr(10) & "Line: " & SOLINE &
Chr(10) & "This line will not be process"
Exit Function
End If
RText = "Sales Order: " & SONUM & " " & Chr(10) & "Line: " & SOLINE &
Chr(10) & "Ready to Process?"
Responce = MsgBox(RText, vbInformation + vbYesNo, cianame())
If Responce = vbYes Then
sqlString = "INSERT INTO PS_HST ( SONUM, SOLINE, QTY, SHIPPER,
SHIPDATE, SHIPTIME ) VALUES (" & SONUM & "," & SOLINE & "," & RQTY & ", '" &
dhGetUserName() & "', CURDATE ( ), CURTIME ( ))"
INSERT_SHP (sqlString)
sqlString = "SELECT COUNT(SONUM) AS SO FROM PS_SHP WHERE SONUM = " &
SONUM & " AND SOLINE = " & SOLINE
CurrentDb.QueryDefs("Server_GETTSHP").SQL = sqlString
If DLookup("[SO]", "Server_GETTSHP") = 0 Then
sqlString = "INSERT INTO PS_SHP ( SONUM, SOLINE, TSHP ) VALUES
(" & SONUM & "," & SOLINE & "," & RQTY & " )"
INSERT_SHP (sqlString)
Else
sqlString = "SELECT TSHP FROM PS_SHP WHERE SONUM = " & SONUM & "
AND SOLINE = " & SOLINE
CurrentDb.QueryDefs("Server_GETTSHP").SQL = sqlString
NQ = RQTY + DLookup("[TSHP]", "Server_GETTSHP")
sqlString = "UPDATE PS_SHP SET TSHP = " & NQ & " WHERE SONUM = "
& SONUM & " AND SOLINE = " & SOLINE
INSERT_SHP (sqlString)
End If
Else
End If
Else
End If
End Function
I have a table where there's a "R" field (Yes/No Type)
For every record where R equals to -1 I have a function that do "something"
I am able to accomplish this by creating a query with a function on it
But couldn't I accomplish this with a while..loop or for....each statement?
How to I read my table and go into each record and read the "R" Field?
Thank you All
Bre-x
'Here is the Query
SELECT SOL.SONUM, SOL.L, SOL.MS, SOL.R, SOL.RQTY,
doSHP([SONUM],[L],[R],[RQTY]) AS DoSHPFunction INTO Temp
FROM SOL;
'Here is the Function
Function doSHP(SONUM, SOLINE, R, RQTY)
If R = -1 Then
If RQTY = 0 Then
MsgBox "Sales Order: " & SONUM & " " & Chr(10) & "Line: " & SOLINE &
Chr(10) & "This line will not be process"
Exit Function
End If
RText = "Sales Order: " & SONUM & " " & Chr(10) & "Line: " & SOLINE &
Chr(10) & "Ready to Process?"
Responce = MsgBox(RText, vbInformation + vbYesNo, cianame())
If Responce = vbYes Then
sqlString = "INSERT INTO PS_HST ( SONUM, SOLINE, QTY, SHIPPER,
SHIPDATE, SHIPTIME ) VALUES (" & SONUM & "," & SOLINE & "," & RQTY & ", '" &
dhGetUserName() & "', CURDATE ( ), CURTIME ( ))"
INSERT_SHP (sqlString)
sqlString = "SELECT COUNT(SONUM) AS SO FROM PS_SHP WHERE SONUM = " &
SONUM & " AND SOLINE = " & SOLINE
CurrentDb.QueryDefs("Server_GETTSHP").SQL = sqlString
If DLookup("[SO]", "Server_GETTSHP") = 0 Then
sqlString = "INSERT INTO PS_SHP ( SONUM, SOLINE, TSHP ) VALUES
(" & SONUM & "," & SOLINE & "," & RQTY & " )"
INSERT_SHP (sqlString)
Else
sqlString = "SELECT TSHP FROM PS_SHP WHERE SONUM = " & SONUM & "
AND SOLINE = " & SOLINE
CurrentDb.QueryDefs("Server_GETTSHP").SQL = sqlString
NQ = RQTY + DLookup("[TSHP]", "Server_GETTSHP")
sqlString = "UPDATE PS_SHP SET TSHP = " & NQ & " WHERE SONUM = "
& SONUM & " AND SOLINE = " & SOLINE
INSERT_SHP (sqlString)
End If
Else
End If
Else
End If
End Function