Results 1 to 15 of 15

Thread: query regarding subform/subreport of msaccess

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    query regarding subform/subreport of msaccess

    Hi,
    i am currently automating msaccess forms using a separate VB application.i ahve encountred a Subform/Subreport in msaccess form.the subreport contains a row........how can i get the values the values of the row using my VB code?

    regards
    vivek.s

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: query regarding subform/subreport of msaccess

    One way may be to simulate the query and filtering that the form is using.
    The form should be attached to a Table or Query. Get that object name.
    Then the subform may have additional filtering, so get that filter from the
    subforms filter property. Once you know all the sources/filters, you can run
    the query with all filters and duplicate the recordset.

    If you have more then one record in the recordset then note which record it
    is that you want, like record #2. Then in your query recordset just look at #2.

    HTH
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Post Re: query regarding subform/subreport of msaccess

    GURU,
    how shud i code it...can u gimme a example..........this waht i am orginally having........i have also attached the screenshot..........

    VB Code:
    1. Set oform = oapp.Forms("frmWorkReports")
    2.     Set obutton = oform.Controls("subCallData")
    3.     obutton.SetFocus

    and how can i run query...........i am accessing msaccess forms from a seperate VB aplication........anyway i wudnt like to run the query.......i have to jus get the MIN (u can see in the screen shot) from the subform.....and get hold of those values

    ps: accessing msaccess forms from seperate VB application is also called VBA is it?

    thanks and regards
    vivek.s
    Attached Images Attached Images  
    Last edited by vivek.shankar; Dec 30th, 2004 at 03:56 PM.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: query regarding subform/subreport of msaccess

    I think it is more suited to call it "MS Office Automation" or MS Access Automation".
    That designates that you are invoking Access from outside the Access VBA
    enviroment. Perhaps we should change the VBA Forum to "MS Office Development" ?

    Anyways, since you are trying to get info from a continuous form, your better
    off running the query because you can not get a particular record instance in
    a continuous form. Its like an array, but arrays are not accessible in VBA/Access.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: query regarding subform/subreport of msaccess

    hi!

    "MSOFFICE DEVELOPMENT" ......yes certainly fitting

    well how can i run query from VB?and it wudnt affect the ms access application, right?
    so no way to get the value without running query?


    thanks and regards
    vivek.s

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: query regarding subform/subreport of msaccess

    No it will not affect the datbase objects or data at all.

    There probably is a way to get the info from the form, but it would take some
    time to figure out. For now we can run the query and if we figure it out and it
    seems better then we can switch.

    You need to start by obtaining the Form's recordsource and filters (if any).
    Then get the subform's filter. Once we have that we will know how to
    duplicate it by way of a query.

    Let me know when you are at that point.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: query regarding subform/subreport of msaccess

    Hi GURU!
    i am completely new to access programming........well how can i gte the record source and filter?i right clicked the subform(design) and source object was given as "frmCallData"............how shud i proceed........

    regards
    vivek.s

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: query regarding subform/subreport of msaccess

    You can either hard code it in, since they dont want any changes to the
    db the object names should stay the same, or use the smae methods to
    access a form and/or controls to get to the forms recordsource property.


    VB Code:
    1. Option Explicit
    2. 'Add reference to MS ActiveX Data Objects 2.x Library
    3. 'Add reference to MS Access xx.Object Library
    4. Private moCnn As ADODB.Connection
    5. Private moRs As ADODB.Recordset
    6. Private moApp As Access.Application
    7.  
    8. Private Sub Command1_Click()
    9.    
    10.     Dim oForm As Access.Form
    11.     Dim sRecordSource As String
    12.     Dim sFilter As String
    13.     Dim sSQL As String
    14.    
    15.     DoCmd.OpenForm "Form1", acDesign, , , acFormReadOnly, acHidden
    16.     Set oForm = moApp.Forms.Item(0)
    17.     sRecordSource = oForm.RecordSource
    18.     If oForm.FilterOn = True Then
    19.         sFilter = oForm.Filter
    20.     Else
    21.         sFilter = vbNullString
    22.     End If
    23.     MsgBox sRecordSource & vbNewLine & sFilter
    24.     'More to follow...
    25.    
    26. End Sub
    27.  
    28. Private Sub Form_Load()
    29.     Set moCnn = New ADODB.Connection
    30.     moCnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\RobDog888.mdb;Persist Security Info=False"
    31.     moCnn.Open
    32.     Set moApp = New Access.Application
    33.     moApp.Visible = True
    34.     moApp.OpenCurrentDatabase "D:\RobDog888.mdb"
    35. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: query regarding subform/subreport of msaccess

    Thanks a lot............I'll try this and get back to u

    regards
    vivek.s

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: query regarding subform/subreport of msaccess

    Question: Is your attachment image a cropped view of your form or is that all
    there is? In other words are you sure its not just a continuous form without a
    subform or is it a Form with a continuous subform in it?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: query regarding subform/subreport of msaccess

    well there is a form and in it there are some tab controls and when i clicked the main part where the records are.......it said it is a subform........well i will attach the entire form now........

    is there another method without executing queries.......



    Thanks and Regards
    s.vivek
    Attached Files Attached Files

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: query regarding subform/subreport of msaccess

    No, it is a subform nested in a tab control.
    We may be able to navigate down to the control but if the subform contains
    more than one record we will have trouble getting the right record. This is
    whay I suggested executing a query duplicating the form. I am testing the
    control theory out, but I am getting ready to leave early for the day. Boss is
    letting us go early with full pay.

    I will pick this up in about 1-2 hours when I get home.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: query regarding subform/subreport of msaccess

    THANKS A LOT FOR THE TROUBLE

    WELL FESTIVE MOOD IS CATCHING UP

    HAPPY NEW YEAR 2005 - 1 DAY

    i wud happily use the query route........but i wud also be grateful if u guide me to the other way as well

    PS: BOSS!!Dont u have a social life!!i guess ur married to VB
    thanks a lot!
    warm regards
    vivek.s
    Last edited by vivek.shankar; Dec 30th, 2004 at 06:27 PM.

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: query regarding subform/subreport of msaccess

    Not sure where your located, but here on the west coast its only Thursday evening.
    I get Friday off with pay plus the weekend. 3 1/2 day weekend. I'm
    married to my beautiful wife, VB comes after family, dog, & cat. We already taking down x-mas decorations already!

    I am working on getting the data the way we have been so fay, but I needed
    to know if you only had one record in the subform or multiple?

    28.5 hours to go!
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: query regarding subform/subreport of msaccess

    Great to hear that from u

    well sometimes there are multiple records too.

    ps: i am located in india..still 10 hrs to go herebut no celebrations this year cause killer tsunami has caused great destruction in our country
    thanks a lot!
    regards
    vivek.s
    Last edited by vivek.shankar; Dec 31st, 2004 at 03:31 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width