?
Solved

OnChange Event of subform with tab control

Posted on 2013-05-10
10
Medium Priority
?
830 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 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