D
Duck
I have a bit of code that is connected to the click event of a button
control. The purpose of is to create a sales order number and then
check to see if it already exists before applying. The theory is that
if it does exists then the last digit would be incremented by one
before writing to the table. My problems seems to be in my SQL
statement and implementing the last "Like" portion of the statement.
It would normally read:
Like strPO & "*"
if it were in the design windows, but no matter what configuration I
use in the VBA code I get an error, ususally a Type Mismatch error.
My table has Sales order numbers both with and without the final "-
x" Here is my code:
Dim strDate As String
Dim strPO As String
Dim strTmp As String
Dim numInc As Integer
Dim strCustID As String
Dim strSql As String
Dim numCnt As Integer
numInc = 1
strDate = CStr(Format(Now(), "yymmdd"))
Debug.Print "The Date part is " & strDate
strCustID = CStr(Me![CustID].Value)
strPO = strDate & "-" & strCustID & "-1"
Me.frmFrameLenses.Form!txtPONo = strPO
strSql = "SELECT Max(tblInventory.SO) AS MaxOfSO FROM tblInventory
"
strSql = strSql & " HAVING ((Max(tblInventory.SO))) Like " & strPO
& "'& " * " &'"
Any ideas would be appreciated
control. The purpose of is to create a sales order number and then
check to see if it already exists before applying. The theory is that
if it does exists then the last digit would be incremented by one
before writing to the table. My problems seems to be in my SQL
statement and implementing the last "Like" portion of the statement.
It would normally read:
Like strPO & "*"
if it were in the design windows, but no matter what configuration I
use in the VBA code I get an error, ususally a Type Mismatch error.
My table has Sales order numbers both with and without the final "-
x" Here is my code:
Dim strDate As String
Dim strPO As String
Dim strTmp As String
Dim numInc As Integer
Dim strCustID As String
Dim strSql As String
Dim numCnt As Integer
numInc = 1
strDate = CStr(Format(Now(), "yymmdd"))
Debug.Print "The Date part is " & strDate
strCustID = CStr(Me![CustID].Value)
strPO = strDate & "-" & strCustID & "-1"
Me.frmFrameLenses.Form!txtPONo = strPO
strSql = "SELECT Max(tblInventory.SO) AS MaxOfSO FROM tblInventory
"
strSql = strSql & " HAVING ((Max(tblInventory.SO))) Like " & strPO
& "'& " * " &'"
Any ideas would be appreciated