Connecting Tech Pros Worldwide Help | Site Map

Close Form if No records

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 03:01 PM
David Mitchell
Guest
 
Posts: n/a
Default Close Form if No records

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.

  #2  
Old November 12th, 2005, 03:01 PM
Allen Browne
Guest
 
Posts: n/a
Default 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]



  #3  
Old November 12th, 2005, 03:01 PM
David Mitchell
Guest
 
Posts: n/a
Default 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]
  #4  
Old November 12th, 2005, 03:03 PM
Allen Browne
Guest
 
Posts: n/a
Default 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]


  #5  
Old November 12th, 2005, 03:03 PM
David Mitchell
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.