View Single Post
  #1 (permalink)  
Old November 11th, 2004, 07:46 PM
wizbang wizbang is offline
Registered User
Join Date: Nov 2004
Location: , , .
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
Reply With Quote