Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Me.Controlname active record instead of record1

Status
Not open for further replies.

marcellvries

Programmer
Jun 4, 2008
20
0
0
EU
Dear all,

I've created a complaint form database where people can enter complaints. If the complaint is resolved, it can be closed by a specific person.

When you click the 'close complaint' button, the system is supposed to check whether two specific fields are filled in. If not, a message is shown. If yes, the current complaint should be closed.

Situation:
I have 2 open complaints (records) and I want to close complaint 2.

Problem:
When I click the 'close' button, the system checks whether the two fields are filled in in Record 1 instead of the active record (2).

In case everything is filled in in record 1, it closes record 1 instead of record 2.

Code:
Private Sub cmdAfwijkingAfsluiten_Click()
    Dim rsAfwijkingAfsluiten As New ADODB.Recordset
    Dim SQLStmt As String
    Me.Requery
    On Error GoTo HandleError
    If IsNull(Me.Tekst82) Then
        MsgBox "Je moet een paraaf apotheker invullen"
        Exit Sub
        End If
    If IsNull(Me.Tekst84) Then
        MsgBox "Je moet een datum invullen"
        Exit Sub
        End If
    If Not IsNull(Me.Volgnummer) And Not IsNull(Me.Tekst82) And Not IsNull(Me.Tekst84) Then
                SQLStmt = "SELECT * FROM tblAfwijkingen WHERE AfwijkingID = " & Me.AfwijkingID
                rsAfwijkingAfsluiten.Open SQLStmt, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
                If Not rsAfwijkingAfsluiten.EOF Then
                    rsAfwijkingAfsluiten!Afgesloten = True
                    rsAfwijkingAfsluiten.Update
                End If
                rsAfwijkingAfsluiten.Close
                Set rsAfwijkingAfsluiten = Nothing
                Me.Requery
                DoCmd.Close
            End If

Question:
What is wrong with using Me.Controlvalue ? What should I change to make sure the field check If IsNull(Me.Tekst82) and the closing action rsAfwijkingAfsluiten!Afgesloten = True are performed on the active record instead of record 1?


Thank you very much in advance for your help.

With kind regards,

Marcel
 
The culprit is here:
Me.Requery

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PHV,

Thank you for your quick response.

I can't remember the reason why I put Me.Requery in the code, but I had one :)

Removing it solves the problem.

Thanks!

Marcell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top