Solved

OnChange Event of subform with tab control

Posted on 2013-05-10
10
822 Views
Last Modified: 2013-05-11
I am trying to create a message box on a subform with tab control prior to moving to the next tab in Access 2003. Basically it asks if they have saved their information. I have put the vba on the change event of the form. What happens is that the message box appears before the subform has loaded.

Dim Qres As Integer
If Qres = vbYes Then
Me.TabCtl40.Pages(intNextPage).SetFocus
Else
Me.TabCtl40.Pages(x).SetFocus
End If
Should I be placing this somewhere else on the form?
Thanks for the help.
0
Comment
Question by:smolbeck367
  • 6
  • 4
10 Comments
 
LVL 14

Expert Comment

by:Bill Ross
ID: 39157100
Hi,

What sets the value of Qres?  What sets x?

Regards,

Bill
0
 

Author Comment

by:smolbeck367
ID: 39157374
I declare Qres as the variable for the response to the yes/no message box. I use x to move through the pages.
Dim x as integer
0
 
LVL 14

Expert Comment

by:Bill Ross
ID: 39157574
Hi,

Where is the message box code?  Where is the code above in the form?  There is not enough info to determine the issue or to see what's happening from the code above.

Please post a sample db if possible and I'll try to help further.

Regards,

Bill
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:smolbeck367
ID: 39158112
Good morning Bill. I appreciate the help.
This is what i have for code on the tabchange event.

Dim x As Integer
Dim Qres As Integer
Dim intCurrPage As Integer
Dim intNextPage As Integer

x = Me.TabCtl40.Value

'Qres = MsgBox("Have you remembered to save your updates?", vbYesNo, "Save records")

Me.txtDate = Right(Me.TabCtl40.Pages(x).Caption, 10)
'If Qres = vbYes Then
'Me.TabCtl40.Pages(intNextPage).SetFocus
'Else
'Me.TabCtl40.Pages(x).SetFocus
'End If

End Sub

My goal is that they cannot move to the next tab until they have saved the current on. i have not done much with forms with tabs.
0
 
LVL 14

Expert Comment

by:Bill Ross
ID: 39158225
Hi,

What is the recordsource of the form?  If the form is a bound form then you can check to see if there are uncommitted changes by checking/setting the forms dirty property.

If me.dirty=true then
  me.dirty = false
endif

You could prompt them to save by changing the code - but why?

The above code will save the record.  

Regards,

Bill
0
 
LVL 14

Expert Comment

by:Bill Ross
ID: 39158227
Continued...

The tab control behaves just like any other control excepts it holds other controls.  If you want changes to be saved between tab changes then just execute the save in the tabs OnChange event which occurs when the user changes tabs.

Regards,

Bill
0
 

Author Comment

by:smolbeck367
ID: 39158229
I will give that a try. Thanks again for the help.
0
 
LVL 14

Accepted Solution

by:
Bill Ross earned 500 total points
ID: 39158242
Ok.  Put the code in the tab control onchange event...

If me.dirty=true then
  me.dirty = false
endif
0
 

Author Closing Comment

by:smolbeck367
ID: 39158587
Thanks for your help.
0
 
LVL 14

Expert Comment

by:Bill Ross
ID: 39158606
Glad to help anytime.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question