Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42298

rstSelseat.EOF is always true?

$
0
0
Hello there,

I am currently using Microsoft Access 2007 with Visual Basic for Applications (VBA 7.1) and am having problems with getting a certain set of sub-routines to function correctly.
Basically, my program is a theater booking system which has a seating arrangement where each button on the form represents a seat. Upon clicking the button, a check should be put into motion to see whether or not the recordset being referenced (rstSelseat) already contains a record of the seat that was selected by the user.
Now, when selecting a seat for the first time, the sub-routine runs flawlessly, and even tells me if the seat has been selected already. However, when attempting to select a second seat, I am presented with the following error:
Quote:

Run-time error '3021':

No current record.
After I saw the error, I decided to take a look at the code to see what was amiss and I soon found something that, in my opinion, was very odd - the recordset rstSelseat was at the end of the file. As such, I decided to add a 'rstSelseat.MoveFirst' to the code, but sadly, this did not fix the issue.

So, after an hour or so of attempting to solve the problem myself, I finally decided to seek help here. If anyone could help me out with this, I would greatly appreciate it! Also, here is a copy of the 'a1' button's sub-routine, which selects the seat A1:
Code:

Private Sub a1_Click()
    Dim lblSeatCaptionA1
    lblSeatCaptionA1 = "A1"
   
    lblSeatValue.Caption = lblSeatCaptionA1
    lblSeat.Visible = True
    lblSeatValue.Visible = True
   
    chosenseat = lblSeatCaptionA1
   
    Dim rstSelseat As DAO.Recordset
    Dim sqlString As String
   
    Set db = CurrentDb()
    Set rstSelseat = db.OpenRecordset("Selseat")

    If rstSelseat.EOF Then
        rstSelseat.AddNew
        rstSelseat!Seat = chosenseat
        rstSelseat.Update
    Else
        Do Until rstSelseat!Seat = chosenseat Or rstSelseat.EOF
            rstSelseat.MoveNext
        Loop
       
        If rstSelseat.EOF Then
        Else
            MsgBox ("You have already selected this seat!")
        End If
    End If

End Sub


Again, thank you for your time!

Viewing all articles
Browse latest Browse all 42298

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>