Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 11th, 2004, 04:34 AM
Registered User
 
Join Date: Jul 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to code this?

I have a tab control with 2 tabs names Jan and Feb.
I also have a textbox to output/
What I would like to do is if I click tab Jan, 1/31/2004 will display in the textbox and 2/28/2004 if I click tab Feb.

I don;t know which tab events this falls.

thanks for your help.

 
Old January 11th, 2004, 05:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

On Enter, or On Click

I am a loud man with a very large hat. This means I am in charge
 
Old January 11th, 2004, 04:51 PM
Registered User
 
Join Date: Jul 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

on enter event is not listed.

 
Old January 12th, 2004, 07:39 PM
Registered User
 
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default



You can use the tab control's "On Change" event.

Here's how.

In my example:
Tab1 is a tab page control with two pages on it
also Txt1 is an unbound textbox on the same form.

Change my code or your controls to match.

Click in the upper right of the tab control. The name of your whole tab control should display in the Properties Dialog box ( Important ! - not the name off the individual pages within the tabe control)

Click the "Events" tab of the Properties Dialog box.

You will see a list of events. Choose "On Change"

click right on the words "On Change".

Then click on the little button with three dots on it ... to the right

Select "Code Builder" from the dialog box that pops up, and OK it

You will see these words pop up in the Code Builder Window that follows.


    Private Sub Tab1_Change()

    End Sub


Add the text below between those two lines:
Dim str1 As String ' str1 is text
Select Case Tab1.Value ' look at the value of the whole tab page control
Case 0 ' tab page indexing begins with "0", not 1
str1 = "1/1/1999"
Case 1
str1 = "1/1/2000"
End Select
MsgBox str1 ' str1 will display in a messagebox
Txt1 = str1 ' Txt1 is set to str1

It should then read as:
Private Sub Tab1_Change()
Dim str1 As String ' str1 is text
Select Case Tab1.Value ' look at the value of the whole tab page control
Case 0 ' tab page indexing begins with "0", not 1
str1 = "1/1/1999"
Case 1
str1 = "1/1/2000"
End Select
MsgBox str1 ' str1 will display in a messagebox
Txt1 = str1 ' Txt1 is set to str1
End Sub

Use whatever names you need for the controls. Use those same names in the code.

Best..

C





Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent:hard disk serial code and vb code ivanlaw Pro VB 6 0 July 25th, 2007 04:05 AM
VB: .Exe file, serial code and activation code ivanlaw Pro VB 6 8 July 6th, 2007 05:44 AM
code clinic - Why wont example asp code work? jardbf Classic ASP Basics 3 April 27th, 2006 06:22 PM
Writing Client Side Script from Code-Behind code sajid_pk Classic ASP Databases 1 January 18th, 2005 12:53 AM
disable forum code within [code] blocks? nikolai Forum and Wrox.com Feedback 0 October 23rd, 2003 07:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.