Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

VB6-Access datacontrol navigation problems

i have a problem with my VB6-Access system

when i hit the previous button from the first record it moves back showing a blank data and hitting the next button shows up an error. here is my code.

the error says: 'Runtime error 3426' this action was cancelled by an associated object.

and when i hit debug it highlights the datwf.recordset.movefirst line in the cmdprev sub.




Private Sub cmdAddnew_Click()

If cmdAddnew.Caption = "&Add New Record" Then
cmdAddnew.Caption = "&Update"
cmdDelete.Caption = "&Cancel Update"

cboService.Enabled = True
txtAdults.Enabled = True
txtChildren.Enabled = True
txtVisitors.Enabled = True
txtDate.Enabled = True

cmdFirst.Enabled = False
cmdNext.Enabled = False
cmdLast.Enabled = False
cmdPrev.Enabled = False



datWF.Recordset.AddNew

ElseIf cmdAddnew.Caption = "&Update" Then
datWF.Recordset.Update

cmdAddnew.Caption = "&Add New Record"
cmdDelete.Caption = "&Delete"

cboService.Enabled = False
txtAdults.Enabled = False
txtChildren.Enabled = False
txtVisitors.Enabled = False
txtDate.Enabled = False

cmdFirst.Enabled = True
cmdNext.Enabled = True
cmdLast.Enabled = True
cmdPrev.Enabled = True


End If










End Sub

Private Sub cmdCancel_Click()
Unload Me
End Sub


Private Sub cmdDelete_Click()
If cmdDelete.Caption = "&Delete Record" Then
If MsgBox("Are you sure you want to delete this record?", vbYesNo) = vbYes Then
datWF.Recordset.Delete
datWF.Recordset.MoveNext

If datWF.Recordset.EOF Then
datWF.Recordset.MoveLast
End If

MsgBox "Record successfully deleted."

End If

ElseIf cmdDelete.Caption = "&Cancel" Then
datWF.Recordset.CancelUpdate

cmdAddnew.Caption = "&Add New Record"
cmdDelete.Caption = "&Delete"

cmdExit.Enabled = True
cmdFirst.Enabled = True
cmdPrev.Enabled = True
cmdNext.Enabled = True
cmdLast.Enabled = True

End If


End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub cmdFirst_Click()

datWF.Recordset.MoveFirst



End Sub

Private Sub cmdLast_Click()

datWF.Recordset.MoveLast





End Sub

Private Sub cmdNext_Click()

datWF.Recordset.MoveNext


If datWF.Recordset.BOF Then
datWF.Recordset.MoveFirst

End If



If datWF.Recordset.EOF Then
MsgBox "You are at the end of your records!"

End If





End Sub

Private Sub cmdPrev_Click()

datWF.Recordset.MovePrevious

If datWF.Recordset.BOF = True Then
datWF.Recordset.MoveFirst




End If


End Sub

'Private Sub datWF_Validate(Action As Integer, Save As Integer)

'If Save = -1 Then
'If MsgBox("Save changes made?", vbYesNo) = vbYes Then
'Save = -1
'Else

'Save = 0
'End If
'End If


'End Sub

Private Sub Form_Load()
cboService.Enabled = False
txtAdults.Enabled = False
txtChildren.Enabled = False
txtVisitors.Enabled = False
txtDate.Enabled = False

End Sub

Comments

Sign In or Register to comment.