Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

How to access datasheet subform on a tab control

Posted on 2013-07-01
18
Medium Priority
?
1,671 Views
Last Modified: 2013-07-02
Hello experts

Im strugling with accessing a subform via VBA which is placed on another form on a tab control.
So the form Im looking for is called: 'TreeLevels subform'. It is placed on form: FormTagValidation which is on tab control's  ("TabCtl0") page - 'Validation'.
Tab control is on form 'FirstStage'.

So to e.g. set focus on FormTagValidation or to set focus on page validation I need to use code:
Forms!FirstStage!FormTagValidation.SetFocus

Forms!FirstStage.TabCtl0.Pages.Item("Validation").SetFocus

Open in new window


Well I cant make it working for 'TreeLevels subform'

My ultimate goal is to apply query to this subform's RecordSource.

cheers
0
Comment
Question by:yahooooo
[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
  • 8
  • 8
  • 2
18 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39291233
try this


Forms!FirstStage!FormTagValidation.Form![TreeLevels subform].Form.RecordSource= "query name"


see this links for reference
http://access.mvps.org/access/forms/frm0031.htm


http://access.mvps.org/access/forms/frm0025.htm
0
 
LVL 3

Author Comment

by:yahooooo
ID: 39291263
So I thought but I got this error


error
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39291321
check the "NAME" of the subform Control  (the control that housed the subform)
and use it in the expression instead of using the name of the subform
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 48

Expert Comment

by:Dale Fye
ID: 39291326
Can you provide a screenshot of the forms in question?  It sounds like you might actually have a main form, subform, nested subform configuration.
0
 
LVL 3

Author Comment

by:yahooooo
ID: 39291354
@capricorn
thats FormTagValidation which hosts subform and no it doesnt work

@Fyed
screen
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39291368
<thats FormTagValidation which hosts subform and no it doesnt work>

i dd not mentioned the name of the form that housed the subform,

i said, the control in form "FormTagValidation" that housed the subform
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 39291401
Where are you attempting to do this from?  Is there a control on the main form, or an even on the main form?

You should be able to use:

Forms!FirstStage!FormTagValidation.Form.Recordsource = queryName

or

Form_FirstStage.FormTagValidation.Form.Recordsource = queryName
0
 
LVL 3

Author Comment

by:yahooooo
ID: 39291547
@capricorn
i tried both:
    Forms!FirstStage!TabCtl0!FormTagValidation![TreeLevels subform].SetFocus
    Forms!FirstStage!TabCtl0![TreeLevels subform].SetFocus
error 451
@Fyed
Im trying to do that from another tab's form. It works find if Im on this form through me.[treelevels subform]...
There is a tab control on the main form
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39291605
yahooooo,

did you look at the second link i posted above?
there is no need to reference the Tab Control to refer to the subform.
0
 
LVL 3

Author Comment

by:yahooooo
ID: 39291618
Yes i know that. Got confused with that control u asked for. Thought you meant that tab control. It's late, deadline in few hours and im sick so good excuse I guess ;)

I created this subform by drag and drop a table on FormTagValidation. Not sure if there is any control over there.
I guess I could move all my controls and this subform straight to the tab control (so remove FormTagValidation) and that should work, but that would be a lot of work...
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39291868
upload a copy of your db..
0
 
LVL 3

Author Comment

by:yahooooo
ID: 39292987
Hope that helps. I replaced original data with few dummy rows and removed forms which weren't relevant
Maint-Build-Tool-v0.04---test2.accdb
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 39293178
yahooo,

from where are you trying to access the subform "TreeLevels subform"?



see this rev.
Maint-Build-Tool-v0.04-rev.accdb
0
 
LVL 3

Author Comment

by:yahooooo
ID: 39293610
Looks like I deleted too many things ;)

I created a button on 'treeview' tab. What I need is perform any operation on TreeLevels subform from treeview. that could be for example: to set focus on TreeLevels subform or to update TreeLevels subform's recordset basing on some query. See commented code in an onclick event
thanks
Maint-Build-Tool.accdb
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39293695
did you look at the rev i uploaded? comment on that first .
0
 
LVL 3

Author Comment

by:yahooooo
ID: 39293833
ok I addapted it to my solution :) works great

so what I was looking for is:
Forms!FirstStage!FormTagValidation.Form![TreeLevels subform].Form.RecordSource = "WrongParent"

Open in new window

and what I missed was " .Form " after FormTagValidation
thanks
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39293854
see my first post at http:#a39291233
0
 
LVL 3

Author Comment

by:yahooooo
ID: 39293953
silly me. I havent noticed that bit :/ sorry for wasting your time bud
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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

647 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