Continuous form record number

H

H. Martins

I have a form whose default view is 'continuous form'.

Then when I click a button I need to delete the record where the mouse
is (was just) placed.

How can I find out the record number?

Alternatively any idea is welcome.

Thanks
Henry
 
D

Dirk Goldgar

H. Martins said:
I have a form whose default view is 'continuous form'.

Then when I click a button I need to delete the record where the mouse
is (was just) placed.

How can I find out the record number?

Alternatively any idea is welcome.

Thanks
Henry


Records don't have inherent record numbers, since they can be sorted in many
different ways. But you don't need a record number to delete a record. If
your button is in the form's detal section, then clicking it will make that
record the current record, and if the button is in the form's header or
footer, the form's current record will remain the same as it was before
clicking the button. Therefore, you can just tell Access to delete the
current record:

RunCommand acCmdDeleteRecord
 
H

H. Martins

Dirk,
and if the button is in the form's header or
footer,

Indeed the case.
the form's current record will remain the same as it was before
clicking the button.  Therefore, you can just tell Access to delete the
current record:

    RunCommand acCmdDeleteRecord

Well, I get "The command or action 'Delete Record' isn't available
now" ...

Just in case, this is the query:

SELECT tblTurmaMatriz.lintTurmaVaziaKSlave, tblAlunos.txtNomeAluno
FROM tblAlunos RIGHT JOIN tblTurmaMatriz ON
tblAlunos.tblAlunosKMaster=tblTurmaMatriz.lintAlunosKSlave WHERE
(((tblTurmaMatriz.lintTurmaVaziaKSlave)=forms.frmTurmaMatriz.cmbbxTurma))
ORDER BY tblAlunos.txtNomeAluno;

I need to delete current record of tblTurmaMatriz.

Thanks
Henry
 
H

H. Martins

Ok.

I got this one running:

Private Sub btnRemover_Click()


Dim rs As DAO.Recordset
Dim RecIndex As Integer
Dim strSelect As String

RecIndex = [lintTurmaMatrizKMaster]

' RunCommand acCmdDeleteRecord

MsgBox RecIndex

If IsNull([Form].[CurrentRecord]) Then ' ******** I suppose it
doesn't work - I'll see later
MsgBox "Erro: Seleccione um registo (clicando com o rato) na
listagem seleccionando, eventualmente, uma turma."
Exit Sub
End If

MsgBox "vai apagar o aluno lintTurmaCheiaKMaster = " & RecIndex

strSelect = "SELECT tblTurmaMatriz.lintTurmaMatrizKMaster FROM
tblTurmaMatriz WHERE tblTurmaMatriz.lintTurmaMatrizKMaster = " &
RecIndex

Set rs = DBEngine(0)(0).OpenRecordset(strSelect)

If Not rs.EOF Then
rs.Delete
End If

rs.Close
Set rs = Nothing

Me.Requery

End Sub

Now, I would prefer something like

Set rs = DBEngine(0)(0).OpenRecordset("qryTurmaMatrizAlunoApaga")
rs.Filter = "lintTurmaMatrizKMaster = """ & RecIndex & """"
rs.Requery '' ****** not sure it is needed

The query "qryTurmaMatrizAlunoApaga" is the same as strSelect

Thanks for help,
Henry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top