[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 836
  • Last Modified:

OnChange Event of subform with tab control

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
smolbeck367
Asked:
smolbeck367
  • 6
  • 4
1 Solution
 
Bill RossCommented:
Hi,

What sets the value of Qres?  What sets x?

Regards,

Bill
0
 
smolbeck367Author Commented:
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
 
Bill RossCommented:
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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
smolbeck367Author Commented:
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
 
Bill RossCommented:
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
 
Bill RossCommented:
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
 
smolbeck367Author Commented:
I will give that a try. Thanks again for the help.
0
 
Bill RossCommented:
Ok.  Put the code in the tab control onchange event...

If me.dirty=true then
  me.dirty = false
endif
0
 
smolbeck367Author Commented:
Thanks for your help.
0
 
Bill RossCommented:
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.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now