Hi,
When I click on the button OkPack, I get type mistmatch...
What I'm trying to do is:
Take the last field in TblPackingSlip, Add 1 to it, then add a new record with the new value (which would be the last value + 1) and display the last value in a text box call txtPackNumber..
Thanks here's the code:
When I click on the button OkPack, I get type mistmatch...
What I'm trying to do is:
Take the last field in TblPackingSlip, Add 1 to it, then add a new record with the new value (which would be the last value + 1) and display the last value in a text box call txtPackNumber..
Thanks here's the code:
Code:
Private Sub cmdOKPack_Click()
On Error GoTo ErrorHandler
Dim Rst As Recordset
Dim MySql As String
Dim LIDNo As String
Dim IDnum As Variant
MySql = "SELECT TblPackingSlip.[PackNumber] From TblPackingSlip"
Set Rst = CurrentDb.OpenRecordset(MySql)
Rst.MoveLast
LIDNo = Rst.Fields("PackNumber")
IDnum = LIDNo + 1
Rst.AddNew
Rst.Fields("PackNumber") = IDnum
Rst.Update
Rst.Close
Set Rst = Nothing
Me.txtPackNumber = IDnum
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End Sub