PC Review


Reply
Thread Tools Rate Thread

Continuous form record number

 
 
H. Martins
Guest
Posts: n/a
 
      1st Jun 2010
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


 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      1st Jun 2010
"H. Martins" <(E-Mail Removed)> wrote in message
news:b4ab14e1-51c6-4c16-8a78-(E-Mail Removed)...
>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

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
 
H. Martins
Guest
Posts: n/a
 
      1st Jun 2010
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

 
Reply With Quote
 
H. Martins
Guest
Posts: n/a
 
      1st Jun 2010
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
add record number to continuous form CuriousMark Microsoft Access Form Coding 4 19th Sep 2009 03:11 AM
RE: add record number to continuous form TonyT Microsoft Access Form Coding 1 18th Sep 2009 11:07 PM
Record Selectors on continuous form seem to select wrong record Garyth Microsoft Access Form Coding 5 9th Jul 2009 04:30 AM
Need to display record number on continuous subform =?Utf-8?B?RGVubmlz?= Microsoft Access Form Coding 3 19th May 2006 10:56 PM
Checkbox on continuous form breaks navigation from record to record Yarik Mezheritsky via AccessMonster.com Microsoft Access Forms 0 2nd Jun 2005 06:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:22 AM.