By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 1,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

runtime error 6 - overflow

P: 1
I m having runtime time error 6 - overflow in the following code. Can anyone help me & sort out my problem.



Private Sub cmdSave_Click()
Dim intCounter As Integer
Dim rsData As New ADODB.Recordset
Dim intId As Integer
Dim blnOneOrTwo As Boolean
Dim intPurchId As Integer

If msfGrid.Rows <= 1 Then
MsgError ("No Purchases To Be Saved")
Exit Sub
End If

rsData.Open "Select Max(Id) as MaxId From PurchiMaster", Con, adOpenForwardOnly, adLockReadOnly
If IsNull(rsData("MaxId")) = True Then
intId = 1
Else
intId = Val(rsData("MaxId"))
End If
rsData.Close

rsData.Open "Select Max(PurchId) as MaxId From PurchiMaster", Con, adOpenForwardOnly, adLockReadOnly
If IsNull(rsData("MaxId")) = True Then
intPurchId = 0
ElseIf Val(rsData("MaxId")) = 0 Then
intPurchId = 0
Else
intPurchId = Val(rsData("MaxId"))
End If
rsData.Close

rsData.Open "PurchiMaster", Con, adOpenDynamic, adLockOptimistic

Dim intVal As Integer

intVal = MsgBox("Confirm", vbYesNoCancel)
'MsgBox intVal
If intVal = vbYes Then
blnOneOrTwo = One
ElseIf intVal = vbNo Then
blnOneOrTwo = Two
ElseIf intVal = vbCancel Then
Exit Sub
End If


With msfGrid
For intCounter = 1 To .Rows - 1
rsData.AddNew
intId = intId + 1
intPurchId = intPurchId + 1
rsData("Id") = intId
rsData("PurchId") = intPurchId
rsData("Date") = Format(dtDate.Value, "dd/mm/yyyy")
rsData("Party") = Trim(.TextMatrix(intCounter, 0))
rsData("PurchiNo") = Val(.TextMatrix(intCounter, 1))
rsData("Desc") = Trim(.TextMatrix(intCounter, 2))
rsData("Qty") = Val(.TextMatrix(intCounter, 4))
rsData("Units") = Trim(.TextMatrix(intCounter, 5))
rsData("Rate") = Val(.TextMatrix(intCounter, 6))
rsData("Amount") = Val(.TextMatrix(intCounter, 7))
'after stock updation
rsData("Desc2") = Trim(.TextMatrix(intCounter, 3))
rsData("ItemId") = Val(.TextMatrix(intCounter, 8))
'after stock updation
rsData("Type") = blnOneOrTwo
rsData.Update

Call InsertInPurchiStock(blnOneOrTwo, intCounter, intId)
Next
End With
'rsData.CancelUpdate
rsData.Close

ButtonValue = None

Call Clear(Me)
msfGrid.Rows = 1

Call EditMode(False)

Set rsData = Nothing
dtDate.SetFocus
End Sub
Apr 13 '07 #1
Share this Question
Share on Google+
1 Reply


Tig201
100+
P: 103
I think this might be your problem

Expand|Select|Wrap|Line Numbers
  1. Dim blnOneOrTwo As Boolean
  2. ....................
  3. blnOneOrTwo = One
  4. ....................
  5. blnOneOrTwo = Two
  6. ....................
  7.  
Try setting “blnOneOrTwo” to True or False or define it as something other than a Boolean.
Apr 13 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.