473,387 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Hiding object in a split form?

Dpot
30
At the top of the form I have "Report ID" which is the primary ID number and "Linked ID #" which is the ID number of the '2nd page' if there is a second page. This form is a split form so the user can click on any piece of data in the table at the bottom. I have 2 labels at the top of the page, one says "Page 1" one says "Page 2" this is there if there are more than 1 page. I'm trying to get it so if the Report ID Value is less than the Linked ID Value then "Page 1" would be visible and vice versa for "Page 2". For the 1st page the Report ID will always be less than the Linked ID # and the 2nd page will always be the other way around. The code is:

Expand|Select|Wrap|Line Numbers
  1. If Me.Report_ID.Value < Me.LinkID.Value Then
  2. Me.Page1.Visible = True
  3. End If
  4. If Me.Report_ID > Me.LinkID.Value Then
  5. Me.Page2.Visible = True
  6. End If
Since this form doesn't open or close or reset I'm not quite sure how to execute this idea. I have pasted it in after update, on focus, data change, data set change of the form as well as the report Id object. I can not for the life of me figure it out. I'm still learning VBA so any input to point me in the right direction would be greatly appreciated.
Dec 2 '14 #1
9 2341
jforbes
1,107 Expert 1GB
The Form OnCurrent Event is usually the place to put code that that you want to be executed when the Current Record changes.
Dec 2 '14 #2
Dpot
30
I tried that :/ Still nothing.
Dec 2 '14 #3
Dpot
30
Page 1 shows, but once I change records nothing happens. It doesn't switch to Page 2.
Dec 2 '14 #4
jforbes
1,107 Expert 1GB
Is your code executing and just not doing what you want? Or is it not executing when you expect it to?

I am a little confused as to what you and the code are attempting to do.
Dec 2 '14 #5
jforbes
1,107 Expert 1GB
You might need to drop a break point into your code and see what values you are getting. It does look a bit strange that the if statement for Page1 and Page2 are the same.
Dec 2 '14 #6
Dpot
30
If the value within report id is less than the value within linked id then show the label for page 1

If the value within report id is greater than the value within linked id then show label for page 2.

This is what I'm trying to do. Code doesn't execute at all... the form opens and the label that says page 1 is visible but that never changes if I go to the next id # (which is linked to the original Id#)
Dec 2 '14 #7
jforbes
1,107 Expert 1GB
I'm confused as to why the code doesn't execute. Maybe try this:
  1. From the Form Design, right-click on the background of your Form. This should get "Form" to show up at the top of your Properties Window.
  2. In the Properties Window, select the Event Tab, then cliek on the "..." for the "On Current" Property and select Code Builder.
  3. Then copy-paste the code below in for your Form_Current. (Be sure to save of a copy of the current code, if any, so that you can revert if need be):
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Dim bVisible As Boolean
  3.     bVisible = (Me.Report_ID.Value < Me.LinkID.Value)
  4.     Me.Page1.Visible = bVisible
  5.     Me.Page2.Visible = (Not bVisible)
  6. End Sub
If you need to, you can put a break in here to see the values of Report_ID and LinkID.

I think you are in a situation where you need to set the visible property on all your controls since you are toggling back and forth.

If you get things setup like this, your code should fire every time the record changes.
Dec 2 '14 #8
jforbes
1,107 Expert 1GB
It just hit me! I should have known better as I've ran into this before. You are using a Split Form which is in a way is two separate instances of the Form running in the same container. I apologize for not catching this earlier as it's this strangeness that brought me to Bytes in the first place: http://bytes.com/topic/access/answer...-a#post3778277

You might want to try this:
Expand|Select|Wrap|Line Numbers
  1. Public Sub callFormCurrent()
  2.     Call Form_Current
  3. End Sub
  4. Private Sub Form_Current()
  5.     If Me.CurrentView = 2 Then
  6.         Forms(Me.Name).callFormCurrent
  7.     Else
  8.         Dim bVisible As Boolean
  9.         bVisible = (Me.Report_ID.Value < Me.LinkID.Value)
  10.         Me.Page1.Visible = bVisible
  11.         Me.Page2.Visible = (Not bVisible)
  12.     End If
  13.  End Sub
When you change records, the Form will determine if it is on the Datasheet (SplitForm) instance or the SingleForm instance. If it is on the SingleForm instance it will just execute the code. If it is on the Datasheet instance, it will call the SingleForm's version of Form_Current.
Dec 2 '14 #9
Dpot
30
Still Nothing. I'll try playing around with the code you provided and hopefully something happens, if not I'll just have to make a whole other form to use as my page 2 but I was hoping to avoid that all together. Thank you so much!
Dec 3 '14 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ARC | last post by:
I posted this before, but no response. Hopefully the MVP folks will know the answer. I'm not sure how other's are using the new split form, but what I like about it is I can design the header...
13
by: geosmy | last post by:
Hi everyone, First post here! I have been trying to upgrade to Acc2007 looking forward to using Split Forms. To my horror I have just discovered that Split Forms do not hold variables at...
9
by: kwerkyone | last post by:
I have two separate but similar databases and each has a split form that acts as the main form used. One of these split forms is able to be filtered from the datasheet portion of the split form using...
5
by: gershwyn | last post by:
I've approached this a couple different ways but I feel like I'm missing the simple solution. I have a split form for data entry which is bound to my Orders table. When you enter an item number,...
1
by: gershwyn | last post by:
Hey all, another question about split forms in Access 2007. Hopefully this one is a quick one. I have a bound spit form for data entry. The split form portion does not allow edits. I want it to be...
0
by: avtuvy | last post by:
My Access 2007 access application includes a split form, The user updates or enters data to the top part of the form (text boxes) and than click a button to save the data. with thedefault settings of...
3
by: Chris Brown | last post by:
For a Split Form, how do I add a Text Box with the label in form above & the control in the datasheet below? I can start over and use the wizard, but to edit an existing split form, to add a field...
6
by: Sandra Walsh | last post by:
Hello - I have a Main form with a Split Form view. I have an OnCurrent event that runs when the user selects a different record in the Split Form. The first part of the OnCurrent event is...
1
by: Sandra Walsh | last post by:
Hello - I have a main form with a record source of t_Trips. Main form has a split form default view. In the properties for the t_Trips table, the Subdatasheet name is set to Table.t_Activities...
6
Seth Schrock
by: Seth Schrock | last post by:
I'm aware that true split forms can't be set as subforms and retain the split form functionality. What I'm trying to do is use two subforms to act like a split form. My main problem is that I want...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.