Connecting Tech Pros Worldwide Forums | Help | Site Map

Close Form if No records

David Mitchell
Guest
 
Posts: n/a
#1: Nov 12 '05
I have a form based on a totals query which lists a recordset of
peoples name where there is no match with tblrelman.

The user then selects from a combo box on the same form the correct
name and clicks a command button which runs an update query correcting
the name and then requeries the recordset.

It is used to correct typos on an imported spreadsheet.

Obviously the recordset decreases by one each time the command button
is clicked.

My problem is that after the last record has been amended and the
requery run I am left with a blank screen.

I need the user to be advised by MsgBox that "All Data has Been
Cleansed" and then the form close.

I have tried various bits of code to count the records and if 0 or
null display message box and have put the code in various event
procedures but can't get it to work.

Any help is greatly appreciated.

Allen Browne
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Close Form if No records


If Me.RecordsetClone.RecordCount = 0 Then ...

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"David Mitchell" <david.a.mitchell@talk21.com> wrote in message
news:c3b0fc6f.0311030027.79574893@posting.google.c om...[color=blue]
> I have a form based on a totals query which lists a recordset of
> peoples name where there is no match with tblrelman.
>
> The user then selects from a combo box on the same form the correct
> name and clicks a command button which runs an update query correcting
> the name and then requeries the recordset.
>
> It is used to correct typos on an imported spreadsheet.
>
> Obviously the recordset decreases by one each time the command button
> is clicked.
>
> My problem is that after the last record has been amended and the
> requery run I am left with a blank screen.
>
> I need the user to be advised by MsgBox that "All Data has Been
> Cleansed" and then the form close.
>
> I have tried various bits of code to count the records and if 0 or
> null display message box and have put the code in various event
> procedures but can't get it to work.
>
> Any help is greatly appreciated.[/color]



David Mitchell
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Close Form if No records


Thanks Allen, but I have already tried this in various event
procedures and it wont work. When the requery is instructed what
events are triggered for the form?



"Allen Browne" <allenbrowne@SeeSig.invalid> wrote in message news:<3fa611ec$0$1731$5a62ac22@freenews.iinet.net. au>...[color=blue]
> If Me.RecordsetClone.RecordCount = 0 Then ...
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html[/color]
Allen Browne
Guest
 
Posts: n/a
#4: Nov 12 '05

re: Close Form if No records


The events to interact.

There may be other events that need to complete before this one can, e.g. if
you try to run this in the AfterUpdate of a control, it will trigger the
form's BeforeUpdate, AfterUpdate, etc, before the Requery can run.

If new records can be added to the form, then the last event should be
Form_Current as it moves to a new record (because there are no more records
left).

Can't you just test the count in the same code that performs the requery?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"David Mitchell" <david.a.mitchell@talk21.com> wrote in message
news:c3b0fc6f.0311030702.7dbaacb9@posting.google.c om...[color=blue]
> Thanks Allen, but I have already tried this in various event
> procedures and it wont work. When the requery is instructed what
> events are triggered for the form?
>
>
>
> "Allen Browne" <allenbrowne@SeeSig.invalid> wrote in message[/color]
news:<3fa611ec$0$1731$5a62ac22@freenews.iinet.net. au>...[color=blue][color=green]
> > If Me.RecordsetClone.RecordCount = 0 Then ...
> >
> > --
> > Allen Browne - Microsoft MVP. Perth, Western Australia.
> > Tips for Access users - http://allenbrowne.com/tips.html[/color][/color]


David Mitchell
Guest
 
Posts: n/a
#5: Nov 12 '05

re: Close Form if No records


> Can't you just test the count in the same code that performs the requery?[color=blue]
>
> --[color=green][color=darkred]
> > > Allen Browne - Microsoft MVP. Perth, Western Australia.
> > > Tips for Access users - http://allenbrowne.com/tips.html[/color][/color][/color]

Did that, works a treat, thank you very much.

David Mitchell
Closed Thread