Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 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 November 11th, 2004, 07:46 PM
Registered User
Join Date: Nov 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can Forms/controls be accessed remotely

I'm not even sure if what I am trying to do is even possible.
The following code works except for the lines with the ???? in front.
The ???? indicates where this code works in a Module (code that is outside the forms class) locally in the Access program but not outside of the program in the separate VB control program I am working in.
The table/recordset operations work just fine. I just am trying, once I open a particular Form, to populate the form with some data.... plus some other stuff but first things first.
Sub Main()
Dim dbs As Database
Dim rst As Recordset
Dim frm As Form
Dim strDatabase As String
Dim strA, strB As String

    strDatabase = "C:\DBTest\Concept.mdb"
    Set dbs = DBEngine.Workspaces(0).OpenDatabase(strDatabase)
    Set rst = dbs.OpenRecordset("Table1")
    With rst
        strA = !ID
        strB = !Field1
    End With
    DoCmd.OpenForm "Frm_TestForm", acNormal
    ???? Set frm = Forms!Frm_TestForm
    ???? frm!txtControlTest.Text = "foobar"
    DoCmd.Close acForm, "Frm_TestForm"
End Sub
When the code runs it opens the database and recordset just fine. The variables contain the correct information and the DoCmd.OpenForm works (although I don't understand why... unless it's because within this procedure opening a database has somehow set up an "environment" that the DoCmd knows about.

The program breaks, hiccups when it comes to theSet frm = Forms!Frm_TestForm statement Runtime Error 13 IT does not know about "Forms!" I was HOPING that since the DoCmd could open the form that "Froms!" would work too! LOL

Since I can't get past the Set statement I don't know if the next statement would bomb also.

Continuing on, if I comment the two questionable lines the form closes and the procedure exits normally.

Does anyone know how the syntax, (if it's even possible) necessary to open a Form and then access the controls and even public sub/functions in the form class.
I tried another approach THAT DID NOT WORK AT ALL
    Set appAccess = CreateObject("Access.Application")
    appAccess.OpenCurrentDatabase ("C:\DBTest\Concept.mdb")
    appAccess.DoCmd.OpenForm "Frm_TestForm"
In this next example, the Form never opened up. I was thinking that somehow that this might have allowed me to get into the Forms Objects/Collections and could somehow be referenced.

If someone has another approach entirely I'm open to that as well ;)
Gee, I hope I haven't confused this issue.
many thanks in advance,

The following code section are various code snippets of the functionality that I use in Access that I would like to do remotely while using VB to control the Access application. I don't know if it's even close to being possible to achieve that level of control. (I have in remote controlling Excell spreadsheets, down to the cell and cell property level but the mechanism is slightly different than working with Access)

Forms!Frm_ProgressForm.frm_display_progress inLevel 

Forms![Frm_ProgressForm]("lbl" & inPos).Caption = inCaption   


If CalFormIsLoaded("Frm_CalendarAppointments") Then
    Forms![Frm_CalendarAppointments].resetAppointmentsCalendar inMonth
End If

If IsLoaded("Frm_ProgressForm") = True Then
         For intIndex = 1 To inNumber
            strLocation = "chk" & Trim(Str(intIndex))
            Forms![Frm_ProgressForm](strLocation).Visible = True
            strLocation = "lbl" & Trim(Str(intIndex))
            Forms![Frm_ProgressForm](strLocation).Visible = True
        Next intIndex

Similar Threads
Thread Thread Starter Forum Replies Last Post
Theme/skin win forms controls planoie .NET Framework 2.0 3 August 21st, 2008 04:28 PM
access other Forms Controls angelboy C# 2005 1 September 9th, 2007 10:35 AM
Activate or Deactivate controls on forms chacquard Access VBA 3 November 27th, 2006 08:03 AM
Let user make forms and controls smang VB.NET 2002/2003 Basics 0 September 2nd, 2005 04:06 PM

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