PC Review


Reply
Thread Tools Rate Thread

Change Page on TAB Control

 
 
Dave G
Guest
Posts: n/a
 
      21st Mar 2007
In Access 2003 I have a form with a TAB control on it with 10 pages.
As a user leaves one page for another I would like to trigger a little
data validation on that page. This almost works using the On Change
event to run a little function. BUT, if the validation fails I want to
stop them going to the newly selected page and keep them on the page
with the problem, but it seems I can't stop them going to the newly
selected page.

Is there a way to either

- prevent them leaving a page, or

- returning to previous page

Thanks
Dave

 
Reply With Quote
 
 
 
 
storrboy
Guest
Posts: n/a
 
      21st Mar 2007
My thoughts are,

The BeforeUpdate event of the form allows you to cancel the current
process if some condition is not met. If the form is bound, then in
theory, all data on the form is related and must be updated at the
same time. Only worry about validation at this point because up until
then, it's still being edited.

In an Unbound form I think the user should either be free to tab
around OR control access to the tabs. One way is to hide the other
tabs when data is being edited and re-enabled when it is saved (or
needs to be validated). Or to control what tab they can move to and
when, provide Next and Previous buttons on the form to move between
the tabs, hiding and unhiding as they move around.

 
Reply With Quote
 
George Nicholson
Guest
Posts: n/a
 
      21st Mar 2007
One approach would be to create a form level variable to contain a reference
to the LastUsedPage (index number or page name).

In the tab control's OnChange event:
- if validation passes, update LastUsedPage variable to new value
- if validation fails, go back to page specified by the (unchanged)
LastUsedPage value.

Note that this doesn't really prevent them from changing pages, but it will
put them back where they "came from" if validation fails.

Notes:
-You would have to provide an initial value for CurrentPage on FormLoad
or something similar.
-Moving back to LastPageUsed on validation failure will (i believe)
cause OnChange to fire a 2nd time. To prevent validation from occuring a 2nd
time, you'd need to structure your code similar to the following air code:

Dim bolValid as boolean

If LastUsedPage <> CurrentPage# then
bolValid = False
'User is trying to change pages. Validate the LastUsedPage
Select Case LastUsedPage
Case 0
'Validate page 0
If x = x then bolValid = true
Case 1
......
End Select
If bolValid = false
' Validation failed. return user to LastUsedPage
Me.MyTabControl = LastUsedPage
End If
End If


HTH,


"Dave G" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In Access 2003 I have a form with a TAB control on it with 10 pages.
> As a user leaves one page for another I would like to trigger a little
> data validation on that page. This almost works using the On Change
> event to run a little function. BUT, if the validation fails I want to
> stop them going to the newly selected page and keep them on the page
> with the problem, but it seems I can't stop them going to the newly
> selected page.
>
> Is there a way to either
>
> - prevent them leaving a page, or
>
> - returning to previous page
>
> Thanks
> Dave
>



 
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
Change Page Order on Tab Control =?Utf-8?B?TmlnZWw=?= Microsoft Access VBA Modules 2 4th May 2006 01:49 PM
Programatically change tab control page properties =?Utf-8?B?Sm9uTUNyb3VjaA==?= Microsoft Access Form Coding 1 8th Mar 2005 04:14 PM
Change tab control page programmatically =?Utf-8?B?UmlwcGVyVA==?= Microsoft Access Form Coding 1 27th Jan 2005 10:05 PM
Change Width of WinForms user control on Web page Joe Microsoft ASP .NET 1 21st Jan 2005 06:25 PM
cancel tab control page-change Rachel Suddeth Microsoft C# .NET 0 13th Sep 2004 03:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:40 AM.