Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Vb problem

  • 19-03-2003 9:06pm
    #1
    Moderators, Computer Games Moderators Posts: 4,569 Mod ✭✭✭✭


    Done with vb 6.0 and Access 2000.

    Right heres the thing.

    As part of my vb project for end of year I have to take in records into a database and view them etc. etc. I also have to be able to delete them

    Now we are not allowed to delete them straight from the database as this would be too easy, err... I mean this would make problems with relationships etc.

    So heres the thing. I've created a field in the database which can be set to yes/no whatever.

    Now when displaying the table you check if the particular field has a yes or no flag and if it has a yes flag you move to the next/previous etc.

    But here is where my problems start.

    Suppose I have a deleted record at the start of the table. If I move "back" into this "deleted" record I must move to the next one. And check if thats deleted etc. etc.

    So I'm using while loops to save typing :D

    It does get very tricky when if for example you have a deleted record at say the first and last entry in the table.

    Heres what I have so far:
    Private Sub cmdPrevious_Click()
    'Command button which moves one place to the right in the database
    With adoDelCompany.Recordset
    .MovePrevious
    While .EOF = True
    .MoveLast
    While ![Deleted] = True
    .MovePrevious

    Wend
    Wend
    txtCompanyID = ![Company ID]
    txtCompanyName = ![Company name]
    txtStreet = ![Street]
    txtTown = ![Town]
    txtCounty = ![County]
    txtTelephoneNumber = ![Telephone Number]
    txtFaxNumber = ![Fax Number]
    txtWebsite = ![Website]
    txtDescription = ![description of business engaged in by the company]
    txtSizeOfCompany = ![Size of Company]
    txtContactPersonsName = ![Contact Person]
    End With
    End Sub

    The error I get is :

    Run-time error '3021':

    Either BOF or EOF is True, or the current record has been deleted.
    Requested operation requires a current record.

    Its completely mystifying me, any help welcome.


Comments

  • Hosted Moderators Posts: 3,290 ✭✭✭TomTom


    It was said to me more times, and even though I don't mean it, you can't use boards.ie to do your homework.

    But anyway
    Try Here


  • Moderators, Computer Games Moderators Posts: 4,569 Mod ✭✭✭✭Ivan


    Originally posted by TomTom
    It was said to me more times, and even though I don't mean it, you can't use boards.ie to do your homework.

    But anyway
    Try Here


    Its not homework, I mean by the time I actually got a usable answer out of boards I'll have it well finished, I'm just curious is all...


  • Registered Users, Registered Users 2 Posts: 950 ✭✭✭jessy


    When you move previous you make no prevision for the possibility that you are at the first record.
    Because if you are at the first record and you try to move previous then it will crash if no prevision is made.
    Are you actually searching through the recordset.

    Why not write a simple SQL statement to retrieve all records with the delete statement set to false/no.


  • Closed Accounts Posts: 9,314 ✭✭✭Talliesin


    Originally posted by Ivan
    Its not homework, I mean by the time I actually got a usable answer out of boards I'll have it well finished, I'm just curious is all...
    Ask then.


This discussion has been closed.
Advertisement